Aulene

Untitled

May 23rd, 2017
1,426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. // SNAKPROC
  2. // Aulene De
  3.  
  4. #include<iostream>
  5. #include<fstream>
  6. #include<cstdio>
  7. #include<cstring>
  8. #include<cmath>
  9. #include<climits>
  10. #include<algorithm>
  11. #include<vector>
  12. #include<map>
  13. #include<queue>
  14. #include<stack>
  15. #include<set>
  16. #include<list>
  17.  
  18. using namespace std;
  19.  
  20. #define lli long long int
  21. #define mod 1000000007
  22. #define p push
  23. #define pb push_back
  24. #define mp make_pair
  25.  
  26. int main()
  27.     {
  28.         int t, n, i;
  29.         char prev, next;
  30.         string s;
  31.         bool ans;
  32.  
  33.         cin >> t;
  34.  
  35.         while(t--)
  36.             {
  37.                 ans=1;
  38.  
  39.                 cin >> n >> s;
  40.                 next = 'H';
  41.  
  42.                 for(i=0; i<n; i++)
  43.                     {
  44.                         if(s[i] != '.')
  45.                             {
  46.                                 if(next == 'T' && s[i] == 'T')
  47.                                     next = 'H';
  48.                                 else if (next == 'H' && s[i] == 'H')
  49.                                     next = 'T';
  50.                                 else
  51.                                     ans = 0;
  52.                             }
  53.                     }
  54.  
  55.                 if(next == 'T')
  56.                     ans=0;
  57.                
  58.                 if(ans)
  59.                     cout << "Valid" << endl;
  60.                 else
  61.                     cout << "Invalid" << endl;
  62.             }
  63.  
  64.         return 0;
  65.     }
Add Comment
Please, Sign In to add comment