标签:blog http io ar os sp on 数据 div
3 [(]) (]) ([[]()])
No No Yes
#include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> #include<string> #include<cmath> #include<queue> #include<vector> #include<set> #include<stack> using namespace std; int n; char ch; stack<char> s; int main() { scanf("%d",&n); getchar(); while(n--) { while(scanf("%c",&ch)&&ch!=‘\n‘) { if(s.empty()) s.push(ch); else { if(ch==‘(‘||ch==‘[‘) s.push(ch); else { if(ch==‘)‘&&s.top()==‘(‘) s.pop(); else if(ch==‘]‘&&s.top()==‘[‘) s.pop(); else s.push(ch); } } } if(s.empty()) printf("Yes\n"); else printf("No\n"); while(!s.empty()) s.pop(); } return 0; }
标签:blog http io ar os sp on 数据 div
原文地址:http://www.cnblogs.com/a972290869/p/4125370.html