Graf_Rav

http://codeforces.com/contest/550/problem/A

May 25th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5. const int XL = 3;
  6. const int XXL = 1000*100;
  7. int main()
  8. {
  9.     int k = 0;
  10.     char a[XL]{"AB"};
  11.     char b[XL]{"BA"};
  12.  
  13.     char t[XXL];
  14.     cin >> t;
  15.  
  16.     int n = strlen(t);
  17.  
  18.  
  19.  
  20.  
  21.         for (int j = 0; j< n-1; j++)
  22.         {
  23.             if (a[0] == t[j] && a[1] == t[j+1])
  24.             {
  25.                 k++;
  26.                 t[j] = '0';
  27.                 t[j+1] = '0';
  28.                 break;//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  29.             }
  30.         }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.         for (int j = 0; j < n-1; j++)
  37.         {
  38.             if (b[0] == t[j] && b[1] == t[j+1])
  39.             {
  40.                 k++;
  41.                 break;//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  42.             }
  43.         }
  44.  
  45.    
  46.  
  47.         if (k >= 2)
  48.         {
  49.             cout << "YES";
  50.         }
  51.  
  52.         else
  53.         {
  54.             cout << "NO";
  55.         }
  56.  
  57.  
  58. }
Add Comment
Please, Sign In to add comment