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 ...
随机推荐
- fiddler笔记:与Web Session的交互
Decode Selected Session 解决响应体显示乱码的问题. AutoScroll Session List 决定Fiddler是否会自动将新增的Session添加到web sessio ...
- 牛客 26C 手铐 (缩环, 树形dp)
先缩环建树, 对于树上个环$x,y$, 假设$x,y$路径上有$cnt$个环(不包括$x,y$), 贡献就为$2^{cnt}$. 这题卡常挺严重的, 刚开始用并查集合并竟然T了. #include & ...
- C#UDP异步通信
using SetingDemo.LogHelp;using SetingDemo.SingleRowDeclare;using System;using System.Collections.Gen ...
- 2.JVM、JRE、JDK之间的关系
诠释一. JDK(java development kit) JDK是Java开发工具包,是整个Java的核心,包括了Java运行环境JRE.Java工具和Java基础类库. JRE(java run ...
- html中正则匹配img
1.正则匹配html中的img标签,取出img的url并进行图片文件下载: /// <summary> /// 将image标签的src属性的url替换为base64 /// </s ...
- 使用webform、websevice来进行ajax请求操作
通过使用webform(asp.net非mvc) .webservice 作为请求接口在前台发送ajax请求:1.前台代码: $.ajax({ type: "POST", //方法 ...
- LLVM使用其他Pass的结果
之前的工作一直集中在clang中,最近有点空闲时间,又重新熟悉了一下Pass的书写过程.(参考LLVM CookBook和http://llvm.org/docs/WritingAnLLVMPass. ...
- 一个用beego写的API项目
beego-api 一个使用beego写的API 支持Api日志 支持Swagger注解文档 项目地址: https://github.com/eternity-wdd/beego-api 使用说明 ...
- openstack 平台P2V迁移
目录 [Openstack]P2V迁移 一.前言 二.前提准备 三.操作步骤 1.安装迁移中转机 2.配置中转机 3.创建存储池(可选) 4.制作virt-p2v的 U盘引导启动工具 5.操作物理机, ...
- 【Day3】项目实战。百度针对Xpath的反爬策略和解决方式
import lxml.etree as le with open('edu.html','r',encoding='utf-8') as f: html = f.read() html_x = le ...