Advertisement
Ahmed_Negm

H

Aug 28th, 2022
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define nl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(),x.end()
  9. #define rall(s)  s.rbegin(), s.rend()
  10. #define getline(s) getline(cin>>ws,s)
  11. #define ceill(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  12. #define pi  3.141592653589793
  13.  
  14. /*
  15. ███╗░░██╗███████╗░██████╗░███╗░░░███╗
  16. ████╗░██║██╔════╝██╔════╝░████╗░████║
  17. ██╔██╗██║█████╗░░██║░░██╗░██╔████╔██║
  18. ██║╚████║██╔══╝░░██║░░╚██╗██║╚██╔╝██║
  19. ██║░╚███║███████╗╚██████╔╝██║░╚═╝░██║
  20. ╚═╝░░╚══╝╚══════╝░╚═════╝░╚═╝░░░░░╚═╝
  21.  
  22. */
  23.  
  24. void Fast_IO(){
  25. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  26. // freopen("filename.in", "r", stdin);
  27. // freopen("filename.txt", "w", stdout);
  28. #ifndef ONLINE_JUDGE
  29. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  30. #endif
  31. }
  32.  
  33.  
  34.  bool regu(string s){
  35.     stack<char>st;
  36.     for(int i=0; i<sz(s); i++){
  37.         if(st.empty()) st.push(s[i]);
  38.         else if(st.top() == '(' and s[i] == ')') st.pop();
  39.         else st.push(s[i]);
  40.     }
  41.     return sz(st) == 0;
  42. }
  43.  
  44.  
  45. void solve(){
  46.   string s; cin>>s;
  47.   if(regu(s)) cout<<"first";
  48.   else{
  49.       if(sz(s) &1) cout<<"first";
  50.       else cout<<"second";
  51.   }
  52.  
  53.  
  54.  
  55. }
  56.  
  57. int main(){
  58.     Fast_IO();
  59. int t =1;
  60. //cin>>t;
  61. while(t--){
  62. solve();
  63. }
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement