CF705B.Spider Man
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 v__i 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 a__i 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.
彼得·帕克想和章鱼博士玩一个关于环的游戏。所谓“环”,是指一个顶点序列,其中第一个顶点与第二个顶点相连,第二个顶点与第三个顶点相连,依此类推,最后一个顶点又与第一个顶点相连。环可以仅由一个孤立顶点构成。
初始时共有 k 个环,其中第 i 个环恰好包含 vi 个顶点。双方轮流进行操作,彼得先手。在每一轮中,当前玩家必须从所有可用的环中选择一个至少包含 2 个顶点的环(例如,该环有 x 个顶点),并将其替换为两个环,其顶点数分别为 p 和 x−p,其中 1≤p<x 由该玩家自行选定。无法进行操作的玩家输掉游戏(并失去生命!)。
彼得希望在真正与章鱼博士对战前,先测试若干组初始环集合的配置。初始时他拥有一个空集合。在第 i 次测试中,他向该集合中加入一个含 ai 个顶点的环(实际上这是一个多重集,因为其中可能包含两个或更多完全相同的环)。每次测试后,彼得都想知道:若双方以当前的环集合为初始状态开始游戏,谁将获胜?
彼得的数学功底相当扎实,但此刻他需要你的帮助。
输入格式
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 _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test.
输入的第一行包含一个整数 n(1≤n≤100000)—— 表示 Peter 即将进行的测试次数。
第二行包含 n 个用空格分隔的整数 a1,a2,…,an(1≤ai≤109),其中第 i 个数表示在第 i 次测试之前所添加的环的顶点数。
输出格式
Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise.
按测试执行的顺序打印所有测试的结果。如果先手玩家获胜,则输出 1,否则输出 2。
输入输出样例
输入#1
3 1 2 3
输出#1
2 1 1
输入#2
5 1 1 5 1 1
输出#2
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 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.
在第一个样例测试中:
在彼得的第一个测试中,只有一个含 1 个顶点的环。先手玩家无法进行任何操作,因此输掉游戏。
在第二个测试中,存在一个含 1 个顶点的环和一个含 2 个顶点的环。在含 1 个顶点的环上,双方均无法进行任何操作。先手玩家可将含 2 个顶点的环替换为两个各含 1 个顶点的环,此时后手玩家无法进行任何操作,因而输掉游戏。
在第三个测试中,环的大小分别为 1、2 和 3。与上一测试类似,在大小为 1 的环上双方均无法操作。先手玩家可将大小为 3 的环替换为一个大小为 1 的环和一个大小为 2 的环。此时环的大小变为 1、1、2、2。后手玩家唯一可行的操作是将某个大小为 2 的环替换为两个大小均为 1 的环,于是环的大小变为 1、1、1、1、2。接着先手玩家将最后一个大小为 2 的环替换为两个大小均为 1 的环,从而获胜。
在第二个样例测试中:
大小为 1 的环等价于不存在(因为双方均无法在其上进行任何操作)。
在彼得的第三个测试中:存在一个大小为 5 的环(其余环不影响结果)。先手玩家有两种选择:将其替换为大小分别为 1 和 4 的两个环,或替换为大小分别为 2 和 3 的两个环。
- 若他将其替换为大小为 1 和 4 的两个环:仅大小为 4 的环有意义。后手玩家会将其替换为两个大小均为 2 的环。先手玩家只能将其中一个大小为 2 的环替换为两个大小均为 1 的环;随后后手玩家对另一个大小为 2 的环执行相同操作。此时先手玩家无法再进行任何操作,因而输掉游戏。
- 若他将其替换为大小为 2 和 3 的两个环:后手玩家会将大小为 3 的环替换为大小分别为 1 和 2 的两个环。此时,除大小为 1 的环外,仅剩两个大小为 2 的环。如前一情形所示,当存在两个大小为 2 的环时,后手玩家获胜。
因此,无论先手玩家如何操作,他都将输掉游戏。
输入解题思路,AI测评打分。不知道怎么写?