Codeforces 893A:Chess For Three(模拟)
题目链接: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(模拟)的更多相关文章
- codeforces 893A Chess For Three 模拟
893A Chess For Three 思路: 直接模拟即可,第一盘永远是A与B开始 代码: #include <bits/stdc++.h> using namespace std; ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- Codeforces 747C:Servers(模拟)
http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...
- Codeforces 740A. Alyona and copybooks 模拟
A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: st ...
- 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 ...
- CodeForces 670 A. Holidays(模拟)
Description On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Ma ...
- Codeforces 280D k-Maximum Subsequence Sum [模拟费用流,线段树]
洛谷 Codeforces bzoj1,bzoj2 这可真是一道n倍经验题呢-- 思路 我首先想到了DP,然后矩阵,然后线段树,然后T飞-- 搜了题解之后发现是模拟费用流. 直接维护选k个子段时的最优 ...
- 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 ...
- CodeForces - 586C Gennady the Dentist 模拟(数学建模的感觉)
http://codeforces.com/problemset/problem/586/C 题意:1~n个孩子排成一排看病.有这么一个模型:孩子听到前面的哭声自信心就会减弱:第i个孩子看病时会发出v ...
随机推荐
- Spring Boot + Spring Cloud 实现权限管理系统 后端篇(十一):集成 Shiro 框架
Apache Shiro 优势特点 它是一个功能强大.灵活的,优秀开源的安全框架. 它可以处理身份验证.授权.企业会话管理和加密. 它易于使用和理解,相比Spring Security入门门槛低. 主 ...
- int(a) 和 (int &) a 及 数据存储地址的探究
做题做到一个很有意思的题 void main() { float a = 1; cout << boolalpha << ((int)a == (int &)a); f ...
- day36 数据库表操作 数据类型 完整性约束
今日内容 1.存储引擎表类型 2.数据类型 3.完整性约束 1.存储引擎表类型 指令: 1.show engines:#查看MySQL所有的引擎, 2.show variables like &quo ...
- bluemix部署(二)构建kubernetes工作环境
本文接上篇.在bluemix中构建kubernetes容器. 1.创建集群 左上角的三横,选容器,然后创建集群. 注意区域,免费版,给个名字,创建集群吧. 继续正在部署,这个可能要15-30分钟,真不 ...
- fastjson 在 springboot中的运用
题记: 项目中开始用是Gson,但是压力测试的时候会出现性能下降明显,不得已换成了fastjson 1.首先引用包 <dependency> <groupId>com.alib ...
- ACID/CAP/BASE 理论知识
ACID是事务的四大特性,想要成为事务,必须具备这四点. Atomicity 原子性体现在对于一个事务来讲,要么一起执行成功要么一起失败,执行的过程中是不能被打断或者执行其他操作的. Consiste ...
- 基于Scrapy-Redis和docker技术在单机上构建分布式爬虫
准备工作: 安装docker https://www.docker.com/docker-ubuntu 选择ce版本 通过docker pull 下载基础镜像,ubuntu16.04, redis, ...
- codeforce150A(简单的求质数问题)
A. Win or Freeze time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- python基础初识介绍以及安装
python介绍 Python的创始人为Guido van Rossum.1989年圣诞节期间,在阿姆斯特丹,Guido为了打发圣诞节的无趣,决心开发一个新的脚本解释程序,做为ABC 语言的一种继承. ...
- connection reset 分析解决(转载)
文章转自:https://my.oschina.net/xionghui/blog/508758;记录下来以便以后复习查阅; 在使用HttpClient调用后台resetful服务时,“Connect ...