logo AlgoBeat OnlineJudge
登录 注册

#216914. [NWERC 2017] Juggling Troupe

内存限制:512 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

From Northwestern Europe Regional Contest (NWERC) 2017 Problem J.

Original problem license: CC BY-SA.


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

A troupe of 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 1 below for an illustration of this process.

Figure 1: Illustration of Sample Input 1. A performance with jugglers.

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.

输入格式

The input consists of one line with a string of length () over the characters 0, 1 and 2. The th character in represents the number of juggling balls initially held by the th person.

输出格式

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

样例

样例输入 1

12100212

样例输出 1

10111111

样例输入 2

000111222000222111222001

样例输出 2

111111101111111111111111