Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- char pepe[100005];
- cin >> pepe;
- int i;
- bool S1=false, S2=false;
- for(i=0; pepe[i]; i++){
- if( pepe[i] == 'A' ){
- if( pepe[i+1]=='B' ){
- S1=true;
- i+=2;
- break;
- }
- }
- }
- for(;pepe[i]; i++){
- if( pepe[i]=='B' )
- if( pepe[i+1]=='A' ){
- S2=true;
- i+=2;
- break;
- }
- }
- if( S1 && S2 ) cout << "YES";
- else {
- S1=false; S2=false;
- for(i=0;pepe[i]; i++){
- if( pepe[i]=='B' )
- if( pepe[i+1]=='A' ){
- S2=true;
- i+=2;
- break;
- }
- }
- for(; pepe[i]; i++){
- if( pepe[i] == 'A' ){
- if( pepe[i+1]=='B' ){
- S1=true;
- i+=2;
- break;
- }
- }
- }
- if( S1 && S2 ) cout << "YES";
- else cout << "NO";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement