-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path550A.cpp
More file actions
72 lines (61 loc) · 845 Bytes
/
550A.cpp
File metadata and controls
72 lines (61 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int n = s.length();
if(n<=3)
{
cout<<"NO";
}
else
{
int flag = -1;
int flag1 = 0;
for(int i = 0; i<=n-2; i++)
{
if(s[i]=='A' && s[i+1] == 'B')
{
flag = i+2;
break;
}
}
if(flag!=-1)
for(int i = flag; i<=n-2; i++)
{
if(s[i]=='B' && s[i+1]=='A')
{
cout<<"YES";
flag1 = 1;
break;
}
}
int flag2 = 0;
if(flag1==0)
{
flag = -1;
for(int i = 0; i<=n-2; i++)
{
if(s[i]=='B' && s[i+1] == 'A')
{
flag = i+2;
break;
}
}
if(flag!=-1)
for(int i = flag; i<=n-2; i++)
{
if(s[i]=='A' && s[i+1]=='B')
{
cout<<"YES";
flag2 = 1;
break;
}
}
}
if(flag2==0 && flag1 ==0)
cout<<"NO";
}
return 0;
}