atcoder#ABC267B. [ABC267B] Split?
[ABC267B] Split?
Score : points
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.
- 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
.
0101110101
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.
0100101001
Yes
0000100110
No
This placement is not a split.
1101110101
No
This is not a split because Pin is not knocked down.