Problem list
Log in
#icpc00187 · ICPC NWERC 2017

Juggling Troupe

Diamond III 3.0 s 2048 MB

At the national centre for computing and advanced circus skills, technical demonstrations by students are strongly encouraged.

A troupe of $n$ novice performers are at this very moment arrayed in a row attempting to put on a juggling show. Unfortunately, none of them are very confident in their craft, and they are struggling. Thus, as soon as an opportunity presents itself, they will try to reduce their part in the performance to make the task easier.

Whenever a juggler has more than one ball in their possession, they will throw one ball to each of their neighbours. In the case that a juggler does not have a neighbour in some direction, they will simply throw the ball offstage instead. Everybody throws their juggling balls simultaneously. The show ends when no juggler has more than one ball.

See Figure below for an illustration of this process.

As a member of the audience, you are not impressed by this performance. However, you do wonder how many balls each of the jugglers will have left at the end of the show.

Input

The input consists of:

  • One line with a string $s$ of length $n$ $(1 \leq n \leq 10^6)$ over the characters 0, 1 and 2. The $i$th character in $s$ represents the number of juggling balls initially held by the $i$th person.

Output

Output a string $s$ of length $n$ over the characters 0 and 1, the $i$th giving the number of juggling balls the $i$th person has at the end of the show.

Example 1

Input
12100212
Output
10111111

Example 2

Input
000111222000222111222001
Output
111111101111111111111111
Source
ICPC NWERC 2017
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code