#include<iostream> using namespace std; int main(void) { int t,i,flag; char c; cin>>t; while(t--) { i=0;flag=1; while(scanf("%c",&c)!=EOF) { if(c=='(') i++; else if(i>=0) --i; else {flag=0;break;} } if(flag&&i==0) cout<<"Yes"<<endl; else cout<<"No"<<endl; } } |
Double click to view unformatted code.