Educational Codeforces Round 33 (Rated for Div. 2) A题
A. Chess For Three
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!
Input
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 ai (1 ≤ ai ≤ 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.
Output
Print YES if the situation described in the log was possible. Otherwise print NO.
input
output
YES
思路:简单的模拟即可。
AC代码:
#include<bits/stdc++.h> using namespace std;
int main(){
int _;
cin>>_;
int flag=;
int arr[_+];
int a,b,c;
a=;b=;c=;
for(int i=;i<=_;i++){
cin>>arr[i];
if(arr[i]==c){
flag=;
}
if(flag){
if(arr[i]==a){
swap(b,c);
}else if(arr[i]==b){
swap(a,c);
}else if(arr[i]==c){
swap(a,b);
}
}
}
if(flag){
puts("YES");
}else{
puts("NO");
}
return ;
}
最新文章
- .Net配置中心-服务端/客户端
- HTTP协议学习---(七)代理
- java线程的理解
- HTML常用标签及其全称
- XML的xPath格式
- 如何使用 AngularJS 的 ngShow 和 ngHide
- JTable 的使用
- VS编辑器主题变换插件-EasyVS
- 模仿ICE的structured panorama小按钮
- JavaScript DOM编程艺术读后感(1)—— 平稳退化
- Java 内存模型- Java Memory Model
- C#学习笔记-状态模式
- 新版Azure CDN HTTPS加速服务正式上线
- mysql的必知技巧
- ANG通证是什么?有关ANG通证的干货都在这里
- [USACO07JAN]Cow School
- chrome自动填表会遮挡input中背景图的问题解决方法
- 20175314 实验一 Java开发环境的熟悉
- C语言运算符优先级和ASCII表
- php的ajax简单实例