#abc297b. B - chess960
B - chess960
Score : points
问题陈述
高桥正在玩一个名为 Chess960 的游戏。他决定编写一段代码来判断一个随机初始状态是否满足 Chess960 的条件。
给定一个长度为八的字符串 ,其中 包含恰好一个 K 和一个 Q,以及恰好两个 R、两个 B 和两个 N。请确定 是否满足以下所有条件:
-
假设从左起第 个和第 个字符()均为
B,则 和 的奇偶性不同。 -
K在两个R之间。更形式化地表述,假设从左起第 个和第 个字符()为R,而第 个字符为K;那么应有 。
以上为通义千问 qwen-max 翻译,仅供参考。
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 and Q, and exactly two R's, B's , and N'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. -
Kis between twoR's. More formally, suppose that the -th and -th characters from the left of areRand the -th isK; then .
Constraints
- is a string of length that contains exactly one
KandQ, 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.
Sample Input 1
RNBQKBNR
Sample Output 1
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.
Sample Input 2
KRRBBNNQ
Sample Output 2
No
K is not between the two R's.
Sample Input 3
BRKRBQNN
Sample Output 3
No
update @ 2024/3/10 12:19:58