#include<bits/stdc++.h> using namespace std; int main(){ int T;cin>>T;getchar(); while(T--){ string s; cin>>s; int count=0; for(int i=0;i<s.length();i++){ if(s[i]=='('){ count++; } else{ count--; } if(count<0) break; } if(count==0){ cout<<"Yes"<<endl; } else{ cout<<"No"<<endl; } } } |
Double click to view unformatted code.