102971: [Atcoder]ABC297 B - chess960

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:32 Solved:0

Description

Score : $200$ 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 $S$ of length eight. $S$ has exactly one K and Q, and exactly two R's, B's , and N's. Determine if $S$ satisfies all of the following conditions.

  • Suppose that the $x$-th and $y$-th $(x < y)$ characters from the left of $S$ are B; then, $x$ and $y$ have different parities.

  • K is between two R's. More formally, suppose that the $x$-th and $y$-th $(x < y)$ characters from the left of $S$ are R and the $z$-th is K; then $x< z < y$.

Constraints

  • $S$ is a string of length $8$ that contains exactly one K and Q, and exactly two R's, B's , and N's.

Input

The input is given from Standard Input in the following format:

$S$

Output

Print Yes if $S$ satisfies the conditions; print No otherwise.


Sample Input 1

RNBQKBNR

Sample Output 1

Yes

The $3$-rd and $6$-th characters are B, and $3$ and $6$ 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

Input

题意翻译

给定一个长度为 $8$ 的字符串 $S$,其中 `R`,`B`,`N` 各有 $2$ 个,`Q` 和 `K` 各 $1$ 个 。 一个好的字符串满足两点要求: 1. `K` 在两个 `R` 之间; 2. 两个 `B` 的位置奇偶性不同。 判断 $S$ 是否为好的字符串,如果是则输出 `Yes`,否则输出 `No`。 Translate by [yanhao40340](https://www.luogu.com.cn/user/674721)。

Output

分数:200分

问题描述

高桥正在玩一个叫做Chess960的游戏。 他决定写一个代码来判断一个随机的初始状态是否满足Chess960的条件。

给你一个长度为8的字符串$S$。$S$中恰好有一个KQ,以及恰好两个RBN。判断$S$是否满足以下所有条件。

  • 假设$S$从左数第$x$个和第$y$个字符是B$;那么$x$和$y$的奇偶性不同。

  • K在两个R之间。更正式地说,假设$S$从左数第$x$个和第$y$个字符是R,第$z$个字符是K$;那么$x<z<y$。

条件

  • $S$是一个长度为$8$的字符串,其中恰好有一个KQ,以及恰好两个RBN

输入

输入从标准输入按以下格式给出:

$S$

输出

如果$S$满足条件,打印Yes;否则打印No


样例输入1

RNBQKBNR

样例输出1

Yes

第$3$个和第$6$个字符是B$,并且$3$和$6$的奇偶性不同。 此外,K在两个R之间。因此,条件得到满足。


样例输入2

KRRBBNNQ

样例输出2

No

K不在两个R之间。


样例输入3

BRKRBQNN

样例输出3

No

HINT

是否满足:K在两个R之间,且两个B的位置奇偶性不一样?

加入题单

上一题 下一题 算法标签: