Description

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 and x - 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 the i-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 2 and 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.

正解:博弈论

解题报告:

  我还想了好久SG,就是想不通怎么处理mex。最后发现我真傻真的,显然一旦一堆石子数量固定,不管如何拆,拆成全是1的次数是固定的。

  也就是说,既然全是1是最终态,然后无论怎么拆,最终次数肯定不会变,那么判一判奇偶性就可以了。一秒变水题。

 //It is made by jump~
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int MAXN = ;
int n,a[MAXN],ans;
inline int getint()
{
int w=,q=;
char c=getchar();
while((c<'' || c>'') && c!='-') c=getchar();
if (c=='-') q=, c=getchar();
while (c>='' && c<='') w=w*+c-'', c=getchar();
return q ? -w : w;
} inline void work(){
n=getint(); for(int i=;i<=n;i++) a[i]=getint();
for(int i=;i<=n;i++) {
ans+=a[i]-;
if(ans%==) printf("2\n"); else printf("1\n");
}
} int main()
{
work();
return ;
}

codeforces 705B:Spider Man的更多相关文章

  1. codeforces 705B B. Spider Man(组合游戏)

    题目链接: B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. Scrapy入门到放弃06:Spider中间件

    前言 写一写Spider中间件吧,都凌晨了,一点都不想写,主要是也没啥用...哦不,是平时用得少.因为工作上的事情,已经拖更好久了,这次就趁着半夜写一篇. Scrapy-deltafetch插件是在S ...

  3. 【模拟】Codeforces 705B Spider Man

    题目链接: http://codeforces.com/problemset/problem/705/B 题目大意: 两个人玩游戏,总共N个数,分别求前I(I=1 2 3...n)个数时游戏的获胜者是 ...

  4. CodeForces 705B Spider Man (水题)

    题意:给定 n 个数,表示不同的环,然后把环拆成全是1,每次只能拆成两个,问你有多少次. 析:也不难,反正都要变成1,所以把所有的数都减1,再求和即可. 代码如下: #pragma comment(l ...

  5. CodeForces 705B Spider Man

    水题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #includ ...

  6. Codeforces 731C:Socks(并查集)

    http://codeforces.com/problemset/problem/731/C 题意:有n只袜子,m天,k个颜色,每个袜子有一个颜色,再给出m天,每天有两只袜子,每只袜子可能不同颜色,问 ...

  7. Codeforces 747D:Winter Is Coming(贪心)

    http://codeforces.com/problemset/problem/747/D 题意:有n天,k次使用冬天轮胎的机会,无限次使用夏天轮胎的机会,如果t<=0必须使用冬轮,其他随意. ...

  8. Codeforces 747C:Servers(模拟)

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

  9. Codeforces 749D:Leaving Auction(set+二分)

    http://codeforces.com/contest/749/problem/D 题意:有几个人在拍卖场竞价,一共有n次喊价,有q个询问,每一个询问有一个num,接下来num个人从这次拍卖中除去 ...

随机推荐

  1. [Docker]学习笔记--简单介绍

    学习docker已经有一段时间了,一直没有静下心来好好总结一下. 最近用docker搭了一整套Gitlab的持续集成环境.(会在下一篇中详细的讲解具体步骤,敬请期待) 感觉是时候写点东西和大家一起分享 ...

  2. LIS(模板)

    记录一下,O(nlgn)的算法求LIS //HHH #include <iostream> #include <stdio.h> #include <string.h&g ...

  3. jQuery之获取select选中的值

    本来以为jQuery("#select1").val();是取得选中的值, 那么jQuery("#select1").text();就是取得的文本. 这是不正确 ...

  4. Exploiting second-order SQL injection 利用二阶注入获取数据库版本信息 SQL Injection Attacks and Defense Second Edition

    w SQL Injection Attacks and Defense  Second Edition Exploiting second-order SQL injection Virtually ...

  5. Oracle数据库用户及表空间操作

    //创建数据表空间 create tablespace test_data datafile '/u01/user_data.dbf' size 50m autoextend on next 50m ...

  6. Android系统移植与调试之------->如何使用PhotoShop转换24位的bmp图片为16位bmp图片

    使用Android移植时候,很多图片都需要16为的bmp格式,所以研究了一下如何从24位转换成16位,供大家参阅 step1:查看bmp图片的属性,如下图所示,是24位的 step2:用PhotoSh ...

  7. Android系统移植与调试之------->Amlogic方案编译步骤

    1. 拷贝Amlogic的SourceCode 切换目录到  /home/roco/work/amlogic/SourceCode/mx0831-0525下将mx0831-0525.tgz拷贝到  / ...

  8. 001 unique string

    以后坚持每一个星期都写记到算法题,不论简单还是难,纯熟娱乐! 描写叙述: 实现一个算法来推断一个字符串中的字符是否唯一(即没有反复).不能使用额外的数据结构. (即仅仅使用主要的数据结构) 代码: # ...

  9. django中admin路由系统工作原理

    一.如图所示 from django.contrib import admin from . import models class zhangsan(admin.ModelAdmin): list_ ...

  10. jquery datepicker日历控件

    地址:http://jqueryui.com/datepicker/ 使用:$( "#datepicker" ).datepicker(); $.datepicker.setDef ...