fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while(t--)
  8. {
  9. int c=0,d=0;
  10. string s;
  11. cin >> s;
  12. for(int i=1;i<s.size()-1;i++)
  13. {
  14. if(s[i]=='(') c++; else c--;
  15. if(c== -1) d++;
  16. }
  17. if(d>0) cout << "YES" << endl;
  18. else cout << "NO" << endl;
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5280KB
stdin
4
(())
(())()()
()
(())(())
stdout
NO
YES
NO
YES