B - Split? Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200

問題文

ボウリングのピンは 1 から 10 の番号が付けられており、上から見ると下図のように配置されます。

0

この図の二つの点線に挟まれた部分をと呼ぶことにします。
例えば、ピン 1, 5 とピン 3, 9 はそれぞれ同じ列に存在します。

いくつかのピンが倒れた状態のうち、特殊なものはスプリットと呼ばれます。
ピンの配置がスプリットであるとは、以下の条件が全て成り立つことを言います。

  • ピン 1 が倒れている。
  • ある二つの異なる列であって、次の条件を満たすものが存在する。
    • それぞれの列には、立っているピンが 1 本以上存在する。
    • それらの列の間に、ピンが全て倒れている列が存在する。

具体例は入出力例を参考にしてください。

さて、あるピンの配置が長さ 10 の文字列 S として与えられます。 i = 1, \dots, 10 について、ピン i が倒れているとき Si 文字目は 0 であり、ピン i が立っているとき Si 文字目は 1 です。
S で表されるピンの配置がスプリットかどうか判定してください。

制約

  • S01 からなる長さ 10 の文字列

入力

入力は以下の形式で標準入力から与えられる。

S

出力

S で表されるピンの配置がスプリットなら Yes を、そうでないなら No を出力せよ。


入力例 1

0101110101

出力例 1

Yes

倒れているピンを灰色で、立っているピンを白色で示すと下図のようになります。

ex0

ピン 5 が立っている列とピン 6 が立っている列の間にはピン 3, 9 が置かれている列が存在しますが、ピン 3, 9 はいずれも倒れているので、この配置はスプリットです。


入力例 2

0100101001

出力例 2

Yes

ex1


入力例 3

0000100110

出力例 3

No

ex2

この配置はスプリットではありません。


入力例 4

1101110101

出力例 4

No

ex3

ピン 1 が倒れていないので、スプリットではありません。

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:

0

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 and 1.

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:

ex0

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

ex1


Sample Input 3

0000100110

Sample Output 3

No

ex2

This placement is not a split.


Sample Input 4

1101110101

Sample Output 4

No

ex3

This is not a split because Pin 1 is not knocked down.