题目链接:http://codeforces.com/problemset/problem/893/A

题意

Alex,Bob,Carl三人下棋,每次只能两个人进行下棋,要求输的那个人当旁观者,然后给出n个输赢情况,1代表Alex赢,2代表Bob赢,3代表Carl赢,判断给出的这n中情况是否符合事实

思路

模拟,因为第一场是Alex和Bob进行,所以设置三个变量,分别代表该场的胜者,败者和旁观者。每次结束对局,对胜者进行判定,看胜者是否是旁观者,如果不是,将败者和旁观者进行交换,否则,停止对局,输出“NO”

AC代码

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int a[maxn];
void change(int a,int b)
{
int t=a;
a=b;
b=t;
}
int main(int argc, char const *argv[])
{
ios::sync_with_stdio(false);
int n;
int a1,a2,a3;
a1=1;//win
a2=2;//lose
a3=3;//watch
cin>>n;
int flag=0;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
{
if(a[i]==a1)
{
int t=a2;
a2=a3;
a3=t;
}
else if(a[i]==a2)
{
int t=a1;
a1=a3;
a3=t;
}
else
{
flag++;
break;
}
}
if(flag)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
return 0;
}

Codeforces 893A:Chess For Three(模拟)的更多相关文章

  1. codeforces 893A Chess For Three 模拟

    893A Chess For Three 思路: 直接模拟即可,第一盘永远是A与B开始 代码: #include <bits/stdc++.h> using namespace std; ...

  2. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  3. Codeforces 747C:Servers(模拟)

    http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...

  4. Codeforces 740A. Alyona and copybooks 模拟

    A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: st ...

  5. Codeforces 716A Crazy Computer 【模拟】 (Codeforces Round #372 (Div. 2))

    A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  6. CodeForces 670 A. Holidays(模拟)

    Description On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Ma ...

  7. Codeforces 280D k-Maximum Subsequence Sum [模拟费用流,线段树]

    洛谷 Codeforces bzoj1,bzoj2 这可真是一道n倍经验题呢-- 思路 我首先想到了DP,然后矩阵,然后线段树,然后T飞-- 搜了题解之后发现是模拟费用流. 直接维护选k个子段时的最优 ...

  8. Codeforces 1090B - LaTeX Expert - [字符串模拟][2018-2019 Russia Open High School Programming Contest Problem B]

    题目链接:https://codeforces.com/contest/1090/problem/B Examplesstandard input The most famous characters ...

  9. CodeForces - 586C Gennady the Dentist 模拟(数学建模的感觉)

    http://codeforces.com/problemset/problem/586/C 题意:1~n个孩子排成一排看病.有这么一个模型:孩子听到前面的哭声自信心就会减弱:第i个孩子看病时会发出v ...

随机推荐

  1. springMVC中对HTTP请求form data和request payload两种数据发送块的后台接收方式

    最近在做项目中发现,前台提交数据时,如果通过form表单提交和ajax发送json时,springMVC后台接收不能都通过@ModelAttribute方式处理,经过一番查找后,ajax发送json请 ...

  2. Oracle中如何停止正在执行SQL语句

    oracle的用P/SQL客户端中,如何停止正在执行的SQL语句? 我们使用oracle语句查询某个表时,如果查询的表数据太多,如何停止正在执行操作 如查询的表数据超过上万条时,如何停止查询操作

  3. python 自然语言处理(二)____获得文本语料和词汇资源

    一, 获取文本语料库 一个文本语料库是一大段文本.它通常包含多个单独的文本,但为了处理方便,我们把他们头尾连接起来当做一个文本对待. 1. 古腾堡语料库 nltk包含古腾堡项目(Project Gut ...

  4. 4.4基于switch语句的译码器

    Q:已知前缀码如右图所示,求0/1字符串“001011101001011001”相对应的译码. a b c 1 01 001 #include<iostream> #include< ...

  5. mysql不会使用索引,导致全表扫描情况

    不会使用索引,导致全表扫描情况 1.不要使用in操作符,这样数据库会进行全表扫描,推荐方案:在业务密集的SQL当中尽量不采用IN操作符 2.not in 使用not in也不会走索引推荐方案:用not ...

  6. unity3D打包发布Apk详细步骤

    1.复制android-sdk-windows文件夹到C盘或者D盘或者你可以找到的任意盘任意目录,注意:不能在中文目录下!! 复制完成之后,打开unity,新建一个项目,打开Edit-Preferen ...

  7. oo作业总结报告2

    第五次作业 多线程电梯 多线程同步和控制的设计策略 明确类和对象,以及是否区分对象实例.具体类可以从类图中看出: 明确线程的类型和数量.输入作为一个线程,调度作为一个线程,三个电梯独立工作,互不影响, ...

  8. Cracking The Coding Interview 1.2

    //原文: // // Write code to reverse a C-Style String. (C-String means that "abcd" is represe ...

  9. IIC协议解释(转)

    IIC协议解释 推荐资源: http://m.elecfans.com/article/574049.html       and       https://blog.csdn.net/firefl ...

  10. python的编码与转码

    编码问题一直是初学者的难题,搞不明白.甚至一些程序员做了多年的程序,但是编码一直整不清,下面就来认识认识编码吧. ASCII(American Standard Code for Informatio ...