102671: [AtCoder]ABC267 B - Split?
Description
Score : $200$ points
Problem Statement
Bowling pins are numbered $1$ through $10$. 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 $1$ and $5$ belong to the same column, and so do Pin $3$ and $9$.
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 $1$ 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 $S$ of length $10$.
For $i = 1, \dots, 10$, the $i$-th character of $S$ is 0
if Pin $i$ is knocked down, and is 1
if it is standing.
Determine if the placement of the pins represented by $S$ is a split.
Constraints
- $S$ is a string of length $10$ consisting of
0
and1
.
Input
Input is given from Standard Input in the following format:
$S$
Output
If the placement of the pins represented by $S$ 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 $5$ and the column containing a standing pin $6$ is a column containing Pins $3$ and $9$. Since Pins $3$ and $9$ 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 $1$ is not knocked down.
Input
Output
分数:$200$分
问题描述
保龄球瓶从$1$到$10$编号。下图是保龄球瓶排列的俯视图:
我们把图中两个虚线之间的一部分叫做一个列。例如,瓶$1$和瓶$5$在同一列,瓶$3$和瓶$9$也在同一列。
当一些瓶子被击倒时,可能会发生一个特殊的情况叫做分瓶。如果满足以下两个条件,瓶子的排列就是一个分瓶:
- 瓶$1$被击倒。
- 有两个不同的列满足以下两个条件:
- 每个列都有一根或多根站立的瓶子。
- 在这些列之间存在一个列,该列中的所有瓶子都被击倒。
参见样例输入和输出以查看例子。
现在,给你一个表示瓶子排列的字符串$S$,长度为$10$。对于$i = 1, \dots, 10$,$S$的第$i$个字符是0
,表示瓶$i$被击倒,是1
表示它站立。确定字符串$S$表示的瓶子排列是否为分瓶。
约束
- $S$是一个长度为$10$的字符串,由
0
和1
组成。
输入
输入从标准输入中给出,格式如下:
$S$
输出
如果字符串$S$表示的瓶子排列为分瓶,打印Yes
;否则,打印No
。
样例输入 1
0101110101
样例输出 1
Yes
在下图中,被击倒的瓶子被涂成灰色,站立的瓶子被涂成白色:
在包含站立瓶$5$的列和包含站立瓶$6$的列之间有一个包含瓶$3$和瓶$9$的列。因为瓶$3$和瓶$9$都被击倒,所以瓶子的排列是一个分瓶。
样例输入 2
0100101001
样例输出 2
Yes
样例输入 3
0000100110
样例输出 3
No
这个排列不是分瓶。
样例输入 4
1101110101
样例输出 4
No
这不是一个分瓶,因为瓶$1$没有被击倒。