Codeforces Round #366 (Div. 2)_B. Spider Man
2 seconds
256 megabytes
standard input
standard output
Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex.
Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p andx - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!).
Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In thei-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins?
Peter is pretty good at math, but now he asks you to help.
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make.
The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test.
Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise.
3
1 2 3
2
1
1
5
1 1 5 1 1
2
2
2
2
2
In the first sample test:
In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses.
In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses.
In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins.
In the second sample test:
Having cycles of size 1 is like not having them (because no one can make a move on them).
In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2and 3.
- If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses.
- If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins.
So, either way first player loses.
水题,判断一下奇偶性就可以了
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=b;++i)
using namespace std; int main(){
int n,cnt=,tp;
scanf("%d",&n);
F(i,,n)
{
scanf("%d",&tp),tp--;
cnt+=tp;
if(cnt&)puts("");
else puts("");
if(cnt&)cnt=;else cnt=;
}
return ;
}
Codeforces Round #366 (Div. 2)_B. Spider Man的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #366 Div.2[11110]
这次出的题貌似有点难啊,Div.1的Standing是这样的,可以看到这位全站排名前10的W4大神也只过了AB两道题. A:http://codeforces.com/contest/705/prob ...
- Codeforces Round #366 (Div. 2)
CF 复仇者联盟场... 水题 A - Hulk(绿巨人) 输出love hate... #include <bits/stdc++.h> typedef long long ll; co ...
- Codeforces Round #366 (Div. 2) B 猜
B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #366 (Div. 2) A , B , C 模拟 , 思路 ,queue
A. Hulk time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
- Codeforces Round #347 (Div.2)_B. Rebus
题目链接:http://codeforces.com/contest/664/problem/B B. Rebus time limit per test 1 second memory limit ...
- Codeforces Round #290 (Div. 2) _B找矩形环的三种写法
http://codeforces.com/contest/510/status/B 题目大意 给一个n*m 找有没有相同字母连起来的矩形串 第一种并查集 瞎搞一下 第一次的时候把val开成字符串了 ...
- Codeforces Round #366 (Div. 2) B
Description Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a ...
- Codeforces Round #366 (Div. 2) C 模拟queue
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
随机推荐
- less基本语法
1.新建less文件 xx.less 和css文件存放在一起 2. 在less文件里声明编码格式 @charset "utf-8"; 3.把项目拖入Koala里 4.选中less文 ...
- 《C++反汇编与逆向分析技术揭秘》——基本数据类型的表现形式
---恢复内容开始--- 基本的浮点数指令 示例代码: Visual Studio 2013的反汇编代码是: 对于movss,表示移动标量单精度浮点值 将标量单精度浮点值从源操作数(第二个操作数)移到 ...
- VR行业未来是会走向巅峰还是会归于落寞?
日前591ARVR资讯网www.591arvr.com根据有关市场调研机构的权威数据分析进行预测表明,全球VR头显出货量将达到1.3亿部,但是现在市场数字不过年出货1700万部,这一部分VR并不指的是 ...
- The property System
The property System 和其它编译器厂商一样, Qt 也提供了复杂的属性机制, 但是作为一个编译器无关.平台无关的库,Qt没有那些不被标准编译器支持的特征, 如 BCB的 __prop ...
- SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'dtdate' 解决方法
小微OAERR: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'mime' at row ...
- JDK版本问题 发展史
jdk是 Java 语言的软件开发工具包,主要用于移动设备.嵌入式设备上的java应用程序.JDK(Java Development Kit) 是 Java 语言的软件开发工具包(SDK).SE(J2 ...
- UltimateDefrag磁盘碎片整理软件 v3.0.100.19汉化版
软件名称:UltimateDefrag磁盘碎片整理软件 v3.0.100.19汉化版软件类别:汉化软件运行环境:Windows软件语言:简体中文授权方式:免费版软件大小:3.25 MB软件等级:整理时 ...
- php函数搜集
数组去重: 方法1:php自带此功能的函数array_unique($arr) 方法2:$arr = array_flip(array_flip($arr)); //这样便可以删除重复元素. 比上面的 ...
- VMware下安装CentOS6.5
一.工具 1.VMware-workstation-full-12.5.0-4352439.exe 2.CentOS-6.5-x86_64-minimal.iso 二.安装VMware虚拟机 1.选择 ...
- com.google.common.collect.Lists#transform使用注意
/** * Returns a list that applies {@code function} to each element of {@code * fromList}. The return ...