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 ;
}
Educational Codeforces Round 33 (Rated for Div. 2) A题的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 33 (Rated for Div. 2) E. Counting Arrays
题目链接 题意:给你两个数x,yx,yx,y,让你构造一些长为yyy的数列,让这个数列的累乘为xxx,输出方案数. 思路:考虑对xxx进行质因数分解,设某个质因子PiP_iPi的的幂为kkk,则这个 ...
- Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query(主席树合并)
题意 给定一棵 \(n\) 个点的带点权树,以 \(1\) 为根, \(m\) 次询问,每次询问给出两个值 \(p, k\) ,求以下值: \(p\) 的子树中距离 \(p \le k\) 的所有点权 ...
- Educational Codeforces Round 33 (Rated for Div. 2) 题解
A.每个状态只有一种后续转移,判断每次转移是否都合法即可. #include <iostream> #include <cstdio> using namespace std; ...
- Educational Codeforces Round 33 (Rated for Div. 2)A-F
总的来说这套题还是很不错的,让我对主席树有了更深的了解 A:水题,模拟即可 #include<bits/stdc++.h> #define fi first #define se seco ...
- 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 ...
- 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 ...
随机推荐
- windows scala helloworld例子详解
[学习笔记] windows scala helloworld例子详解: 在操作系统中,我们的Test3.scala会生成Test3.class,然后class文件被虚拟机加载并执行, 这一点和jav ...
- (四)循环队列 VS 数组队列 (效率对比)
目录 背景 测试代码 结果 链表 随机访问 背景 各自完成插入 10万.20万 条随机数,然后再将这些随机数出队列 : 测试代码 /** * 测试速度 */ public String testSpe ...
- 第九章 MIZ702 ZYNQ片上ADC的使用
9.0难度系数★☆☆☆☆☆☆ 9.1实验概述 这次借助zynq的内嵌的XADC来采集zynq内部的一些参数: •VCCINT:内部PL核心电压 •VCCAUX:辅助PL电压 •VREFP:XADC ...
- Centos7搭建在线yum源
1: 首先关闭防护墙或者设置规则通过且关闭selinux Systemctl diablefirewalld 永久关闭防火墙 vim/etc/sysconfig/selinux 并修改SELINUX ...
- 研究旧项目, 常用 sql 语句
1. select all table select TABLE_NAME from CodingSystem.INFORMATION_SCHEMA.TABLES where TABLE_TYPE = ...
- vue学习(7)-路由抽离
cnpm i vue-router -S
- 测试clang-format的格式化效果
我自己写的业余框架已告一段落,主体功能已完成,剩下的就是优化.第一个要优化的,就是代码格式.我一直是用编辑器写代码的,从之前的UltraEdit到notepad++到sublime text,再到现在 ...
- JS__POST
RSA加密 熟悉的东西 public key Encrypt (函数) 而且 每次刷新都会变化() 一般 128 位,也有 256位的
- 前端基础(六):Bootstrap框架
Bootstrap介绍 Bootstrap是Twitter开源的基于HTML.CSS.JavaScript的前端框架. 它是为实现快速开发Web应用程序而设计的一套前端工具包. 它支持响应式布局,并且 ...
- linux基础2-cd、mkdir、touch、umask、chattr、lsattr、SUID/SGID/Sticky Bit
一 cd : . 代表当前目录 .. 代表上一层目录 - 代表前一个工作目录 ~ 代表[目前用户身份]所在的自家目录 与cd效果相同 ~account 代表 account 这个用户的自家家目录 二m ...