#include<stdio.h> #include<string.h> #include<stdio.h> #include<stdlib.h> int main() { int t,i; scanf("%d",&t); //getchar(); while(t--) { char s[100010]; int k=0; scanf("%s",s); // getchar(); for(i=0;i<strlen(s);i++) { if(s[i]=='(') k++; else if(s[i]==')') k--; if(k<0) break; } if(k==0) printf("Yes\n"); else printf("No\n"); } return 0; } |
Double click to view unformatted code.