fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std ;
  4. bool check(string s)
  5. {
  6. deque<char>d;
  7. for(ll i =0 ; i < s.length();i++)
  8. {
  9. if(s[i]=='(')
  10. {
  11. d.push_back('(');
  12. }
  13. else
  14. {
  15. if(d.empty())
  16. {
  17. cout<<"s"<<endl;
  18. return false;
  19. }
  20. else
  21. {
  22. d.pop_front();
  23. }
  24. }
  25. }
  26. if(d.empty())
  27. return true;
  28. else
  29. return false;
  30. }
  31. int main()
  32. {
  33. ios_base::sync_with_stdio(false);
  34. cin.tie(0);
  35. cout.tie(0);
  36. // freopen(".INP","r",stdin);
  37. // freopen(".OUT","w",stdout);
  38. string s ;
  39. cin>>s;
  40. cout<<check(s)<<endl;
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
1