Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- const int XL = 3;
- const int XXL = 1000*100;
- int main()
- {
- int k = 0;
- char a[XL]{"AB"};
- char b[XL]{"BA"};
- char t[XXL];
- cin >> t;
- int n = strlen(t);
- for (int j = 0; j< n-1; j++)
- {
- if (a[0] == t[j] && a[1] == t[j+1])
- {
- k++;
- t[j] = '0';
- t[j+1] = '0';
- break;//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- }
- }
- for (int j = 0; j < n-1; j++)
- {
- if (b[0] == t[j] && b[1] == t[j+1])
- {
- k++;
- break;//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- }
- }
- if (k >= 2)
- {
- cout << "YES";
- }
- else
- {
- cout << "NO";
- }
- }
Add Comment
Please, Sign In to add comment