#include "stdlib.h" #include "algorithm" #include "iostream" #include <cstdio> #include "string" #include <iomanip> #include <map> #include <set> #include "math.h" using namespace std; map<int, bool> mp; set<string> st; int main() { int t; cin >> t;string str; getchar(); while (t--) { int left = 0; getline(cin, str); int len = str.length(); for (int i = 0; i < len; i++) { if (str[i] == '(')left++; if(str[i]==')')left--; if (left < 0)break; } if (left == 0)cout << "Yes" << endl; else cout << "No" << endl; } return 0; } |
Double click to view unformatted code.