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 ;
}

Educational Codeforces Round 33 (Rated for Div. 2) A题的更多相关文章

  1. Educational Codeforces Round 33 (Rated for Div. 2) D题 【贪心:前缀和+后缀最值好题】

    D. Credit Card Recenlty Luba got a credit card and started to use it. Let's consider n consecutive d ...

  2. Educational Codeforces Round 33 (Rated for Div. 2) C题·(并查集变式)

    C. Rumor Vova promised himself that he would never play computer games... But recently Firestorm — a ...

  3. Educational Codeforces Round 33 (Rated for Div. 2) B题

    B. Beautiful Divisors Recently Luba learned about a special kind of numbers that she calls beautiful ...

  4. Educational Codeforces Round 33 (Rated for Div. 2) E. Counting Arrays

    题目链接 题意:给你两个数x,yx,yx,y,让你构造一些长为yyy的数列,让这个数列的累乘为xxx,输出方案数. 思路:考虑对xxx进行质因数分解,设某个质因子PiP_iPi​的的幂为kkk,则这个 ...

  5. Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query(主席树合并)

    题意 给定一棵 \(n\) 个点的带点权树,以 \(1\) 为根, \(m\) 次询问,每次询问给出两个值 \(p, k\) ,求以下值: \(p\) 的子树中距离 \(p \le k\) 的所有点权 ...

  6. Educational Codeforces Round 33 (Rated for Div. 2) 题解

    A.每个状态只有一种后续转移,判断每次转移是否都合法即可. #include <iostream> #include <cstdio> using namespace std; ...

  7. Educational Codeforces Round 33 (Rated for Div. 2)A-F

    总的来说这套题还是很不错的,让我对主席树有了更深的了解 A:水题,模拟即可 #include<bits/stdc++.h> #define fi first #define se seco ...

  8. Educational Codeforces Round 33 (Rated for Div. 2) D. Credit Card

    D. Credit Card time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  9. Educational Codeforces Round 33 (Rated for Div. 2) C. Rumor【并查集+贪心/维护集合最小值】

    C. Rumor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

随机推荐

  1. Win7 Eclipse 搭建spark java1.8编译环境,JavaRDD的helloworld例子

    [学习笔记] Win7 Eclipse 搭建spark java1.8编译环境,JavaRDD的helloworld例子: 在eclipse oxygen上创建一个普通的java项目,然后把spark ...

  2. (六)springMvc 和 mybatis 整合

    目录 文章目录 @[toc] 整合 dao 层 整合 springMvc #整合思路 整合是将spring 看做是一个大的容器,将其他东西整合进来,是以 spring 为大环境的: 整合 spring ...

  3. thinkphp5日志文件权限的问题

    由于www用户和root用户(比如command的cli进程日志)都有可能对log文件进行读写. 如果是由www用户创建的log文件,不会出任何问题. 但是如果是先由root用户创建的log文件,然后 ...

  4. opencv实现人脸识别(二) 人脸图像采集模块

    这一步我们开始搭建第一个模块,用来检测到图像中的人脸位置,并将它拍下来保存在指定路径 流程图: 代码实现: import cv2 def pic(cam): # 调用笔记本内置摄像头,所以参数为0,如 ...

  5. 二、python数据类型、字符编码、文件处理

    一. 前言 1. 什么是数据: x = 10,10就是我们要存储的数据 2. 为何数据要分不同的类型 数据是用来表示状态的, 不同的状态就应该用不同类型的数据去表示 3. 数据类型 数字(整型.长整型 ...

  6. Docker 容器学习笔记

    Docker 诞生于2013年,最初发起者是dotCloud公司.Docker自开源后受到广泛的关注和讨论,目前已有多个相关项目逐渐形成了围绕Docker容器的生态体系,由于Docker在业界造成的影 ...

  7. Oracle笔记2

    24.复杂查询的三道题 # 案例一:列出与SCOTT从事相同工作的所有员工及部门名称.人数.平均工资 GROUP BY使用限制: 查询语句中没有GROUP BY,则SELECT子句中只能出现统计函数; ...

  8. 利用element-ui封装地址输入的组件

    我们前端做项目时,难免会遇到地址输入,多数情况下,我们都是提供一个省市三级联动,加上具体地址输入的Input输入框给用户,用以获取用户需要输入的真实地址.在需要对用户输入的数据进行校验的时候,我们会单 ...

  9. MySQL设置自增字段

    1.MySQL每张表只能有1个自增字段,这个自增字段即可作为主键,也可用作非主键使用,但是请注意将自增字段当做非主键使用时必须为其添加唯一索引,否则系统将会报错 )将自动增长字段设置为主键 CREAT ...

  10. StoneTab标签页CAD插件 3.1.0

    //////////////////////////////////////////////////////////////////////////////////////////////////// ...