文理学院程序设计在线练习


Meeting

Time Limit: 2 Second(s)    Memory Limit: 32 MB

Total Submission(s): 24   Accepted Submission(s): 8
Problem Description

N (2 <= N <= 1000) people get together to have a meeting. They sit in a straight line. Thus, each one will only see adjacent people (both on his left and on his right). Specially, the first one will only see the second one, the last one will only see the (N-1)-th one. People will always feel sleepy during the meeting. It’s a strange thing that people will feel sleepier when they see other people sleepy.
We define Si(Si = 0, 1, 2, 3) as the i-th people’s initial sober degree. There are four conditions below:
1. Si = 0: he will fall asleep at the beginning of the meeting immediately.
2. Si = 1: If he sees anyone fall asleep, he will fall asleep immediately.
3. Si = 2: If all people he can see fall asleep, he will fall asleep immediately.
4. Si = 3: He will never fall asleep.
We assume that the meeting will last long enough time, and people who fall asleep will not wake up before the end of the meeting. You should determine for each people, whether he will fall asleep during the meeting or not.

Input

There are multiple cases.
For each case, the first line is a integer N (2 <= N <= 1000), indicating the number of the people. The second line contains N integers (Si = 0, 1, 2, 3), indicating the initial sober degree of the i-th people.

Output

For each case, output N integers, indicating each people’s status in order. Print 1 if he will fall asleep during the meeting, otherwise print 0.

Sample Input
3
1 0 1
3
2 0 2
3
0 2 1
3
1 0 3
Sample Output
1 1 1
1 1 1
1 0 0
1 1 0
Source

2015绍兴市计算机技能竞赛