Chess For Three (模拟)

Threejs-Chess: 创建互动3D国际象棋游戏 Three.js 是一个基于WebGL的JavaScript 3D库,它极大地简化了WebGL的学习曲线,提供了场景、相机、渲染器、几何体、材质、光源等丰富的3D对象。在开始使用之前,首先需要将其引入到你的HTML文件中。可以使用CDN链接、npm包或者其他方式来完成这一工作。-- 使用CDN链接 -->一旦Three.js被正确引入,就可以开始创建你的第一个3D场景了。下面的代码展示了如何创建一个基本的场景,添加一个立方体,并使用WebGL渲染器在页面上渲染它。// 创建场景// 创建相机。 阅读详情

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.

Examples
Input
3
1
1
2
Output
YES
Input
2
1
2
Output
NO
Note

In the first example the possible situation is:

  1. Alex wins, Carl starts playing instead of Bob;
  2. Alex wins, Bob replaces Carl;
  3. Bob wins.

The situation in the second example is impossible because Bob loses the first game, so he cannot win the second one.

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    int n;
    int a[110];
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    int ing1 = 1,ing2 = 2;//参赛者
    int watch = 3;//观众
    int flag = 1;
    for(int i = 0; i < n; i++){
       if(a[i] == ing1){//第一个赢
          swap(ing2,watch);//旁观者和输的交换
       }
       else if(a[i] == ing2){//第二个赢同理
          swap(ing1,watch);
       }
       else{
          flag = 0;
          break;
       }
    }
    if(flag) printf("YES\n");
    else printf("NO\n");
    return 0;
}


生成式深度学习(第二版)-第一章-Conda环境下TensorFlow和Keras的安装和配置 按照书籍中的代码运行提示,需要配置Docker。个人的机器上正好有 conda4.14.0,索性就在本地环境进行配置。 阅读详情

相关推荐

使用 arxiv-sanity 实时跟进自己研究领域的Paper

介绍 arxiv.org是一个非常大的预印本资源库,里面有大量的最新的论文,但缺点是浏览、搜索和排序不是很方便。这个资源库每天会更新大量的论文,如果通过手动搜索和浏览则效率很低,高引用的好文章难以及时的找到并阅读,造成时间的浪费。因此 使用 ...

John's Blogs 8277

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进行,所以设置三个变量,分别代表该场的胜者,败...

执念 359

FreeRTOS-Plus-CLI使用笔记

FreeRTOS-Plus-CLI使用笔记 一、简介 详细介绍可参考FreeRTOS-Plus-CLI官网地址入口 FreeRTOS+CLI(Command Line Interface, 命令行接口)提供了一种简单、小型、可扩展且RAM高效的方法,使FreeRTOS应用程序能够处理命令行输入。添加一条指令的步骤如下: 提供一个实现命令功能的函数 将命令映射到该功能函数 注册命令 运行命令解释器 命令行调试接口对于排查分析出现的问题提供了很好的接口,可以通过查看传感器信息判断传感器是否正常,可以查看内置

ApexYuan 6962

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 ...

码农的一亩三分地 358

用废旧汽车电池DIY家用UPS:手把手教你低成本搭建Wi-Fi不断电系统

本文详细介绍了如何利用废旧汽车电池DIY低成本家用UPS系统,确保Wi-Fi设备在断电时持续供电。通过精选材料、电路搭建和安全防护,实现高效稳定的电源转换与智能切换,成本仅为市售UPS的三分之一。特别适合家庭办公和远程工作者提升网络供电可靠性。

weixin_29200485的博客 462

【LOGO动态替换】记录一次关于LOGO动态替换引发的uboot代码分析及其实现

文章目录1.前言2.实现2.1 新增logo分区2.2 制作logo分区镜像2.2.1 查看logo.bmp和logo_kernel.bmp的文件大小。2.2.2 按规则将bmp写入logo.img3.分析3.1 uboot的启动分析3.2 uboot bmp load 显示部分3.2.1 rockchip_show_logo3.2.2 load_bmp_logo3.2.3 load_bmp_logo3.3 uboot bmp read部分3.3.1 read_logo_bmps3.3.1 read_bmp

wang 恒 的博客 1212

893A Chess For Three

模拟题意三个人下棋,每次两个人下,赢的人和第三个人下棋。,每次记录赢的那个人。 第一次只能第一个alex和Bob下,他们其中一个胜利的人,然后和carl下,我们就用carl替换输掉bob,每次用看比赛的人替换掉输掉的那个人。 A. Chess For Three time limit per test1 second memory limit per test256 megabytes i

memory_qianxiao的博客 576

为什么一个“时间片”能折腾 Linux 十年?

时间片扩展不是抢占调度器的控制权,也不是提升优先级。在“非常短暂、非常确定”的用户态临界区内,避免线程被不必要地抢占。用户态自旋锁(user-space spinlock)无系统调用的极短临界区高并发、低延迟的数据结构操作RSEQ(Restartable Sequences)保护区间一旦线程在临界区被抢占,系统整体性能反而下降。线程 A 拿着一个用户态锁线程 B 被调度上来,开始自旋等这个锁但 A 因为时间片用完,被调度器切走CPU 白白空转,所有线程都在浪费时间。

网络技术联盟站 253

Codeforce 893A Chess For Three (模拟)

题目大意:三个人一起下象棋,一局只能2个人同时下,还有一个人要旁观,所以游戏规则是:第一局规定Alex和Bob下,Carl围观,后面则按照输的人去围观轮流来下棋。问题是:输入一组数据,为赢的人的顺序,让你判断这种赢的顺序是否可能,可能的话输出YES,否则输出NO。 解题思路:每一局输的人则不能参加下一轮游戏,根据这一点来判断,直接模拟下棋过程。具体看代码 代码如下: #inc

猴子姑娘呀的博客 727

C# Modbus协议全解析 万字长文|RTU/TCP/UDP完整实战(寄存器映射+多从站组网+NModbus4工业级代码)

你做C#工业上位机开发,Modbus协议是绕不开的终极核心,没有之一!Modbus是由施耐德在1979年发布的工业级串行通信协议,经过40余年的发展,已经成为工业自动化领域的通用标准协议—— 小到温湿度传感器、智能电表、小型PLC,大到变频器、伺服驱动器、DCS集散控制系统,99%的工业设备都原生支持Modbus协议(RTU/TCP二选一,多数全支持)。很多开发者觉得Modbus「知识点杂、协议分支多、组网难」,本质是只掌握了零散的读写代码,没吃透。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 1062

【深度学习时间序列预测案例】零基础入门经典深度学习时间序列预测项目实战(附代码+数据集+原理介绍)

本专栏整理了《深度学习时间序列预测案例》,内包含了各种不同的基于深度学习模型的时间序列预测方法,例如LSTM、GRU、CNN(一维卷积、二维卷积)、LSTM-CNN、BiLSTM、Self-Attention、LSTM-Attention、Transformer等经典模型,包含项目原理以及源码,每一个项目实例都附带有完整的代码+数据集。

优快云 精品推荐 4万+

codeforces893A chess for three题解

第一次遇到A一点思路都没有……最后写了个栈还WA掉了,看到题解觉得很巧妙。惯例说说题意,三个人在做无聊的双人游戏,但是这样对第三个人很不友好。于是他们制定了一个规则:先第一个和第二个人玩,然后胜者和第三个人玩。就这样roll。 他们将胜利情况记录下来,但是又怀疑其正确性。 现在想要让你检验是否合法。 比如: 参加者 参加者 胜者 记录 1 2 1 1 1

LiRewriter的博客 496

Android-Zygote进程的诞生—从init到Zygote启动

Android Zygote进程启动流程解析 Android系统的Zygote进程是所有应用进程的父进程,由init进程创建。启动流程分为: 内核阶段:加载init进程(PID=1) init进程阶段: 挂载基础文件系统(tmpfs、proc等) 设置SELinux安全策略 解析init.rc配置文件 Zygote启动:init进程通过app_process启动Zygote,预加载系统资源 SystemServer:Zygote fork出系统服务进程 关键点: init是用户空间第一个进程......

保持专注,保持热爱 636

codeforces 893A Chess For Three 模拟

893A Chess For Three 思路: 直接模拟即可,第一盘永远是A与B开始 代码: #include <bits/stdc++.h> using namespace std; #define _for(i,a,b) for(int i=(a); i<(b); ++i) #define _rep(i,a,b) for(int i=(a); i<=(b...

ddqb3235的博客 168

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

codeforces 893A. Chess For Three(模拟)

题意:Alex, Bob and Carl,三个人想一起游戏,但是每局游戏只能两个人玩,于是他们决定谁输了就换另一个人玩,我们用1表示Alex,2表示Bob,3表示Carl。给一个N表示他们完了N局游戏,下面N个数字表示当前局获胜的人,下面的日志描述的情况是可能的输出YES,否则输出NO。 思路:模拟即可。用p1,p2表示当前在玩游戏的人,那么剩下那个人编号为6 - p1 - p2。 #i

张松超的博客 391

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Educational Codeforces Round 33 (Rated for Div. 2) A. Chess For Three【模拟/逻辑推理】

A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex, Bob and Carl will soon participate in a tea...

weixin_30757793的博客 83

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

chess for three A

在 cf上看到这个题,觉得这个题很有意思,所以决定把这个记录下来。 这个题是三人下棋。题目如下: A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard input output standard

Xzzzw0618的博客 3412

Codeforces Edu 33 A 893A Chess For Three

若校学渣第一次来写博客了,虽然已经大三了,但是还是希望我的博客对新手有帮助吧 A. Chess For Three time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Alex, Bob and Carl will soon parti

Lewis_Fehling的博客 479

A. Chess For Three

time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex, Bob and Carl will soon participate in a team chess tourname

无知的我 880

【Educational Codeforces Round 33 A】Chess For Three

【链接】 我是链接,点我呀:) 【题意】 在这里输入题意 【题解】 模拟题.知道哪个人是旁观者就好 【代码】 /* 1.Shoud it use long long ? 2.Have you ever test several sample(at least therr) yourself? 3.Can you promise that the...

685

CodeForces 893A Chess For Three

Description: 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

这是一个正经的RR 【Seriously 667

Educational Codeforces Round 33 (Rated for Div. 2) A题. Chess For Three

A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex, Bob and Carl will soon participate i...

aboc43983的博客 130
上一篇: Moon Game FZU - 2148 (计算几何,叉积判断对角线)
下一篇: RunningMan FZU - 2221 (思维!!)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值