304680: CF893A. Chess For Three

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Chess For Three

题意翻译

## 题目描述 A,B,C 三人下棋,A和B先下,每次下完棋之后由现在观战的人(例如第一局就由C)代替下输的人。 每次输入一个数表示谁赢了(A是1,B是2,C是3),如果每一次输入的赢家都不是当时旁观者,则输出 “YES”,否则输出“NO”。 ## 输入输出格式 **输入格式:** 第一行输入正整数n(n≤100),表示比赛局数。 接下来n行,每一行输入一个正整数ai(1≤ai≤3),表示此局赢家 **输出格式:** 如果此过程中不存在旁观者胜利,则输出“YES”,否则输出“NO”。(没有引号) ## 说明 第一个样例顺序: A:B,A胜 A:C,A胜 A:B,B胜 第二个样例B输了第一场,可是他第二场赢了,矛盾,输出“NO”。

题目描述

Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not three. So they play with each other according to following rules: - Alex and Bob play the first game, and Carl is spectating; - When the game ends, the one who lost the game becomes the spectator in the next game, and the one who was spectating plays against the winner. Alex, Bob and Carl play in such a way that there are no draws. Today they have played $ n $ games, and for each of these games they remember who was the winner. They decided to make up a log of games describing who won each game. But now they doubt if the information in the log is correct, and they want to know if the situation described in the log they made up was possible (that is, no game is won by someone who is spectating if Alex, Bob and Carl play according to the rules). Help them to check it!

输入输出格式

输入格式


The first line contains one integer $ n $ ( $ 1<=n<=100 $ ) — the number of games Alex, Bob and Carl played. Then $ n $ lines follow, describing the game log. $ i $ -th line contains one integer $ a_{i} $ ( $ 1<=a_{i}<=3 $ ) which is equal to $ 1 $ if Alex won $ i $ -th game, to $ 2 $ if Bob won $ i $ -th game and $ 3 $ if Carl won $ i $ -th game.

输出格式


Print YES if the situation described in the log was possible. Otherwise print NO.

输入输出样例

输入样例 #1

3
1
1
2

输出样例 #1

YES

输入样例 #2

2
1
2

输出样例 #2

NO

说明

In the first example the possible situation is: 1. Alex wins, Carl starts playing instead of Bob; 2. Alex wins, Bob replaces Carl; 3. Bob wins. The situation in the second example is impossible because Bob loses the first game, so he cannot win the second one.

Input

题意翻译

## 题目描述 A,B,C 三人下棋,A和B先下,每次下完棋之后由现在观战的人(例如第一局就由C)代替下输的人。 每次输入一个数表示谁赢了(A是1,B是2,C是3),如果每一次输入的赢家都不是当时旁观者,则输出 “YES”,否则输出“NO”。 ## 输入输出格式 **输入格式:** 第一行输入正整数n(n≤100),表示比赛局数。 接下来n行,每一行输入一个正整数ai(1≤ai≤3),表示此局赢家 **输出格式:** 如果此过程中不存在旁观者胜利,则输出“YES”,否则输出“NO”。(没有引号) ## 说明 第一个样例顺序: A:B,A胜 A:C,A胜 A:B,B胜 第二个样例B输了第一场,可是他第二场赢了,矛盾,输出“NO”。

加入题单

算法标签: