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