B. Spider Man
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise.

Examples
input
3
1 2 3
output
2
1
1
input
5
1 1 5 1 1
output
2
2
2
2
2
Note

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的更多相关文章

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

  2. Codeforces Round #366 Div.2[11110]

    这次出的题貌似有点难啊,Div.1的Standing是这样的,可以看到这位全站排名前10的W4大神也只过了AB两道题. A:http://codeforces.com/contest/705/prob ...

  3. Codeforces Round #366 (Div. 2)

    CF 复仇者联盟场... 水题 A - Hulk(绿巨人) 输出love hate... #include <bits/stdc++.h> typedef long long ll; co ...

  4. Codeforces Round #366 (Div. 2) B 猜

    B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

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

  6. Codeforces Round #347 (Div.2)_B. Rebus

    题目链接:http://codeforces.com/contest/664/problem/B B. Rebus time limit per test 1 second memory limit ...

  7. Codeforces Round #290 (Div. 2) _B找矩形环的三种写法

    http://codeforces.com/contest/510/status/B 题目大意 给一个n*m  找有没有相同字母连起来的矩形串 第一种并查集 瞎搞一下 第一次的时候把val开成字符串了 ...

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

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

随机推荐

  1. es5 数组

    一. 数组申明 var a = new Array(5)  会生成一个长度为5 每个元素都是undifined的数组 var a = new Array(1,2,3) 跟 var a = [1,2,3 ...

  2. Reprint: Serialization

    Having just recently ran into some major serialization issues I’m going to list some of the errors a ...

  3. [其他]Android SDK离线文件路径以及安装更新方法

    一.离线安装Android SDK文件路径 转载自:http://www.oschina.net/code/snippet_1539302_45940 Google TV Addon, Android ...

  4. The property System

    The property System 和其它编译器厂商一样, Qt 也提供了复杂的属性机制, 但是作为一个编译器无关.平台无关的库,Qt没有那些不被标准编译器支持的特征, 如 BCB的 __prop ...

  5. NYOJ-1057 寻找最大数(三)(贪心)

    寻找最大数(三) 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 给出一个整数N,每次可以移动2个相邻数位上的数字,最多移动K次,得到一个新的整数. 求这个新的整数的 ...

  6. Zabbix 监控rabbitmq

    一 应用场景描述 测试环境业务 OpenStack中搭建了rabbitmq作为RPC消息队列,所以mq起到了很重要的角色,本案例是来如何使用zabbix监控 rabbitmq业务 二 Rabbitmq ...

  7. win10 Qt 调试器未设置

    安装win10后一直用vs调试,没有用qt调试,这次启动调试,发现提示调试器未设置. 解决办法: 需要重新安装wdk 10 https://developer.microsoft.com/zh-cn/ ...

  8. iOS 如何随意的穿插跳跃,push来pop去

    OS 如何随意的穿插跳跃,push来pop去 主题思想:如A.B.C.D 四个视图控制器 想要在 A push B 后, B 在push 到 D ,然后从 D pop 到 C ,在从 C pop 的A ...

  9. 浏览器内核控制Meta标签说明(内核渲染优先问题)

    渲染优先选择极速模式 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> ...

  10. Namespacing in PHP (php 中使用命名空间)

    最近学习一下php的命名空间,中文文档不多,搜到一篇英文的,讲的还蛮系统的,特此翻译一下,以备以后查阅,大家有什么高见或更深刻或者 更悟透的见解希望能不吝赐教,晚辈感激不尽. 原文: http://c ...