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 ...
随机推荐
- ubuntu安装jdk的两种方法
方法一: 这种方法比较简单,保证虚拟机网络畅通就可以了 sudo apt-get update sudo apt-get install default-jre sudo apt-get instal ...
- chrome浏览器如何在本地安装谷歌访问助手教程
许多用户都需要使用谷歌的gmail,搜索.我们目前可以用谷歌访问助手解决google无法访问的问题.那么谷歌访问助手在chrome浏览器中如何安装和使用呢?今天我们详细介绍. 本地安装谷歌访问助手的步 ...
- 学习Sass(一)
一.什么是sass? 写过css的都知道,css是用来改变页面样式的.但它不是一种编程语言,没有变量,函数,继承等功能,只能一条条抒写样式语句很死板.在这个工具决定效率的时代,这是不能容忍的事情.怎样 ...
- Win32窗口
#include <Windows.h> #include <CommCtrl.h> #pragma comment(lib, "comctl32.lib" ...
- LoRaWAN_stack移植笔记(一)--RF硬件相关
和硬件相关的问题 TCXO 的使用 根据SX1276数据手册, 如果使用TCXO,则需要配置RegTcxo寄存器为0x19,代码如下 ``` c void SX1276SetTcxoConfig(vo ...
- 爬虫代码实现五:解析所有分页url并优化解析实现类
如图,我们进入优酷首页,可以看到电视剧列表,我们称这个页面为电视剧列表页,而点击进入某个电视剧,则称为电视剧详情页.那么如何获取所有分页以及对应的详情页呢,通过下面的分页得到. 因此,首先,我们将St ...
- Python学习笔记——进阶篇【第九周】———MYSQL操作
Mysql 增删改查操作 查看数据库 show databases; 创建数据库并允许中文插入 create database s12day9 charset utf8; 使用数据库 use s12d ...
- WinForm 布局,容器、打印和对话框控件
今天,我主要学习了容器控件.打印控件.对话框控件. 在正式进行今天的内容之前,首先补充了布局的两个属性:Anchor:锁定位置,Dock:填充位置,一般与容器控件配合使用. 之后,我学习了第一部分内容 ...
- html 页面太长滚动时,固定页面菜单标签,或者导航标签的位置,fixed/stickUp the position
有时你曾经需要把页面上的某些东西当页面太长发滚动的时候保留置顶位置显示,或许你有别的实现方式,我这个仅供参考, 源代码: /*global $, jQuery, alert*/ (function ( ...
- oracle数据库 参数open_cursors和session_cached_cursor详解!
open_cursors 每个session(会话)最多能同时打开多少个cursor(游标) session_cached_cursor 每个session(会话)最多可以缓存多少个关闭掉的curso ...