You are given a binary string of length , i.e. each character of is either or .
You would like to convert every character of
into
.
To achieve this, you can perform the following
operation:
However, there is one restriction:
You cannot perform two consecutive operations
on adjacent indices.
That is, if you operate on the sequence of
indices
, then for each
the condition
must hold.
Determine whether it is possible to make the entire string consist of only zeros under these conditions.
0 and 1.
For each test case, output a single string
on a new line — YES if it is
possible to convert the entire string to all
zeros under the given rule, or
NO otherwise.
You may print each character of the string
in uppercase or lowercase (for example, the
strings YES, yEs,
yes, and yeS will
all be treated as identical).
5 2 00 3 001 3 101 3 111 2 11
Yes Yes Yes No No
Test case : No operations are needed.
Test case
:
There is a single
at position
.
Simply perform one operation with
, and the string becomes
as desired.
Test case
:
There are two
's, at positions
and
.
Perform one operation with
, and the next operation with
, and we're done.
Test case
:
There are three ones, at positions
.
It's not possible to operate on all of them,
because:
Thus, there's no way to make everything .