atcoder#ABC297B. [ABC297B] chess960
[ABC297B] chess960
Score : points
Problem Statement
Takahashi is playing a game called Chess960. He has decided to write a code that determines if a random initial state satisfies the conditions of Chess960.
You are given a string of length eight. has exactly one
K
andQ
, and exactly twoR
's,B
's , andN
's. Determine if satisfies all of the following conditions.
- Suppose that the -th and -th characters from the left of are
B
; then, and have different parities. K
is between twoR
's. More formally, suppose that the -th and -th characters from the left of areR
and the -th isK
; then .
Constraints
- is a string of length that contains exactly one
K
andQ
, and exactly twoR
's,B
's , andN
's.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if satisfies the conditions; print No
otherwise.
RNBQKBNR
Yes
The -rd and -th characters are B
, and and have different parities.
Also, K
is between the two R
's. Thus, the conditions are fulfilled.
KRRBBNNQ
No
K
is not between the two R
's.
BRKRBQNN
No