#abc267b. B - Split?
B - Split?
Score : points
问题描述
保龄球瓶从1到10编号。下图是球瓶排列的俯视图:
让我们将图中两条虚线之间的每一部分称为列。 例如,球瓶1和5属于同一列,球瓶3和9也属于同一列。
当某些球瓶被击倒时,可能会出现一种特殊的情况,称为分隔(split)。 如果满足以下两个条件,则球瓶的位置被视为分隔情况:
- 球瓶1被击倒。
- 存在两列不同的列,且这两列都满足以下条件:
- 每列中至少有一个站立的球瓶。
- 在这两列之间存在一列,其中所有球瓶都被击倒。
参见样例输入和输出以获得示例。
现在,你得到一个长度为10的字符串来表示球瓶的状态。对于,的第个字符如果是0
,表示球瓶已被击倒;如果是1
,则表示球瓶仍然站立。
请确定由字符串表示的球瓶位置是否构成分隔情况。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Bowling pins are numbered through . The following figure is a top view of the arrangement of the pins:
Let us call each part between two dotted lines in the figure a column.
For example, Pins and belong to the same column, and so do Pin and .
When some of the pins are knocked down, a special situation called split may occur.
A placement of the pins is a split if both of the following conditions are satisfied:
- Pin is knocked down.
- There are two different columns that satisfy both of the following conditions:
- Each of the columns has one or more standing pins.
- There exists a column between these columns such that all pins in the column are knocked down.
See also Sample Inputs and Outputs for examples.
Now, you are given a placement of the pins as a string of length . For , the -th character of is 0
if Pin is knocked down, and is 1
if it is standing.
Determine if the placement of the pins represented by is a split.
Constraints
- is a string of length consisting of
0
and1
.
Input
Input is given from Standard Input in the following format:
Output
If the placement of the pins represented by is a split, print Yes
; otherwise, print No
.
Sample Input 1
0101110101
Sample Output 1
Yes
In the figure below, the knocked-down pins are painted gray, and the standing pins are painted white:
Between the column containing a standing pin and the column containing a standing pin is a column containing Pins and . Since Pins and are both knocked down, the placement is a split.
Sample Input 2
0100101001
Sample Output 2
Yes
Sample Input 3
0000100110
Sample Output 3
No
This placement is not a split.
Sample Input 4
1101110101
Sample Output 4
No
This is not a split because Pin is not knocked down.
update @ 2024/3/10 11:16:21