2657Meeting

2657   Meeting

题目描述

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 SiSi=0,1,2,3as 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.

输入格式:

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.

输出格式:

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.

输入样例 复制
3
1 0 1
3
2 0 2
3
0 2 1
3
1 0 3
输出样例 复制
1 1 1
1 1 1
1 0 0
1 1 0

说明

9
28
通过提交
时空限制1000ms/32mb
题目来源数据结构实验与竞赛训练
评测方式在线评测
题目类型
难        度