Advertisement
_Andreea_

An_pbinfo_dp

Feb 24th, 2022
1,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("an.in");
  6. ofstream fout("an.out");
  7.  
  8. int t;
  9.  
  10. int main()
  11. {
  12.     fin>>t;
  13.     while(t)
  14.     {
  15.         int n;
  16.         char s[10001];
  17.         bool c[10001];
  18.         fin>>s;
  19.         n=strlen(s);
  20.         c[n-1]=1;
  21.         for (int i=n-2; i>=0; i--)
  22.             if(s[i]!=s[i+1])
  23.                 c[i]=1-c[i+1];
  24.             else
  25.                 c[i]=1;
  26.         fout<<c[0]<<'\n';
  27.         t--;
  28.     }
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement