#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; getchar(); while (t--) { string str; getline(cin, str); int left = 0; int right = 0; for (int i = 0; i < str.length(); i++) { if (str[i] == '(')left++; else if(left!=0)left--; } if (left == 0)cout << "Yes" << endl; else cout << "No" << endl; } return 0; } |
Double click to view unformatted code.