Created
October 13, 2015 07:09
-
-
Save jo32/92e028fd89454bf8da30 to your computer and use it in GitHub Desktop.
CODEFORCE 550A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| s = raw_input() | |
| minAB = len(s) + 1 | |
| maxAB = -1 | |
| minBA = len(s) + 1 | |
| maxBA = -1 | |
| for i in range(len(s) - 1): | |
| if [s[i], s[i + 1]] == ['A', 'B']: | |
| minAB = i if i < minAB else minAB | |
| maxAB = i if i > maxAB else maxAB | |
| if [s[i], s[i + 1]] == ['B', 'A']: | |
| minBA = i if i < minBA else minBA | |
| maxBA = i if i > maxBA else maxBA | |
| if maxBA - minAB > 1 or maxAB - minBA > 1: | |
| print 'YES' | |
| else: | |
| print 'NO' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment