暑假练习赛 003 A Spider Man

A - Spider Man

Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

Input

Output

Sample Input

Sample Output

Hint

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.

Sample Input

Input

31 2 3

Output

211

Input

51 1 5 1 1

Output

22222

Sample Output

Hint

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.

/*十分水的题目,后悔死了,题目太长懒得搞看懂题意之后......*/
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string.h>
#define N 100010
#define M 100000
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    int t;
    long long a,s=0;
    scanf("%lld",&t);
    for(int i=1;i<=t;i++)
    {
        scanf("%lld",&a);
        //if(a==1)
        s+=a;
        long long t=s-i;
        if(t%2)
            puts("1");
        else
            puts("2");
    }
    return 0;
}
时间: 2024-10-05 23:56:20

暑假练习赛 003 A Spider Man的相关文章

暑假练习赛 003 F Mishka and trip

F - Mishka and trip Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Description Input Output Sample Input Sample Output Hint Description Peter Parker wants to play a g

暑假练习赛 003 B Chris and Road

B - Chris and Road Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice _ uDebug Description Input Output Sample Input Sample Output Hint Description And while Mis

暑假练习赛 007 E - Pairs

E - Pairs Description standard input/outputStatements In the secret book of ACM, it’s said: “Glory for those who write short ICPC problems. May they live long, and never get Wrong Answers” . Everyone likes problems with short statements. Right? Let’s

暑假练习赛 007 B - Weird Cryptography

Weird Cryptography Description standard input/outputStatements Khaled was sitting in the garden under an apple tree, suddenly! , well... you should guess what happened, an apple fell on his head! , so he came up with a new Cryptography method!! The m

暑假练习赛 007 C - OCR

C - OCR Description standard input/outputStatements Optical Character Recognition (OCR) is one of the most famous fields of Artificial Intelligence. The main purpose of OCR is to recognize printed text (or handwriting) and convert it to the machine e

暑假练习赛 004 E Joint Stacks

Joint StacksCrawling in process... Crawling failed Time Limit:4000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5818 uDebug Description Input Output Sample Input Sample Output Hint Description A stack is a d

暑假练习赛 006 B Bear and Prime 100

Bear and Prime 100Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 680C uDebug Description Input Output Sample Input Sample Output Hint Description

暑假集训练习赛题解

比赛链接:http://acm.nyist.net/JudgeOnline/problemset.php?cid=205 对于第一道题 UFS(Union  Find  Set) ,请参见http://blog.csdn.net/u011632342/article/details/37814289,题目大意一样,解法一样,不过后台测试数据还没整太多,数据比较弱... 对于第二道题STR(STRing),本来是想着给大家"送福利"呢,可能由于我的题目表述能力不太好或者样例数据的特殊性或

spider RPC更新至2.0.0-RELEASE

spider使用java语言开发,使用Spring作为IoC容器,采用TCP/IP协议,在此基础上,结合SaaS金融交易系统的特性进行针对性和重点设计,以更加灵活和高效的满足金融交易系统多租户.高可用.分布式部署的要求.spider默认采用JSON作为序列化机制,后续版本可能会考虑支持protobuf(java/c++/c#均有类库支持). 为了最大化性能以及稳定性,spider基于Oracle JDK1.8进行编译并应避免使用deprecated特性. 为了尽可能的适应各环境以及互联网应用,s