fork 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. string s;
  10. int c=0,d=0;
  11.  
  12. cin >> s;
  13. for(int i=0;i<s.size();i++)
  14. {
  15. if(s[i]=='(')
  16. {
  17. c++;
  18. }
  19. else
  20. {
  21. c--;
  22. }
  23. if(c==0)
  24. {
  25. d++;
  26. }
  27. }
  28. if(d>1) cout << "YES" << endl; else cout << "NO" << endl;
  29.  
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5260KB
stdin
4
(())
(())()()
()
(())(())
stdout
NO
YES
NO
YES