HDU 4664 Triangulation(2013多校6 1010题,博弈)
Triangulation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 96 Accepted Submission(s): 29
No, you are wrong. This is not a computational geometry problem.
Carol
and Dave are playing a game with this points. (Why not Alice and Bob?
Well, perhaps they are bored. ) Starting from no edges, the two players
play in turn by drawing one edge in each move. Carol plays first. An
edge means a line segment connecting two different points. The edges
they draw cannot have common points.
To make this problem a bit
easier for some of you, they are simutaneously playing on N planes. In
each turn, the player select a plane and makes move in it. If a player
cannot move in any of the planes, s/he loses.
Given N and all n's, determine which player will win.
Following are 2*T lines. For every two lines, the first line is N; the second line contains N numbers, n1, ..., nN.
Sum of all N <= 106.
1<=ni<=109.
1
2
2
2 2
Dave
/*
* Author: kuangbin
* Created Time: 2013/8/8 11:54:23
* File Name: 1010.cpp
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <time.h>
using namespace std;
const int MAXN = ;
int sg[MAXN];
bool vis[MAXN];
int mex(int x)
{ if(sg[x]!=-)return sg[x];
if(x == )return sg[x] = ;
if(x == )return sg[x] = ;
if(x == )return sg[x] = ;
if(x == )return sg[x] = ;
memset(vis,false,sizeof(vis));
for(int i = ;i < x-;i++)
vis[mex(i)^mex(x-i-)] = true;
for(int i = ;;i++)
if(!vis[i])
return sg[x] = i;
} int SG(int x)
{
if(x <= )return sg[x];
else
{
x %= ;
x += *;
return sg[x];
}
} int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
memset(sg,-,sizeof(sg));
for(int i = ;i <= ;i++)
{
sg[i] = mex(i);
}
int T;
int n;
int a;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
int sum = ;
for(int i = ;i < n;i++)
{
scanf("%d",&a);
sum ^= SG(a);
}
if(sum)printf("Carol\n");
else printf("Dave\n");
}
return ;
}
HDU 4664 Triangulation(2013多校6 1010题,博弈)的更多相关文章
- HDU 4705 Y (2013多校10,1010题,简单树形DP)
Y Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submiss ...
- HDU 4685 Prince and Princess (2013多校8 1010题 二分匹配+强连通)
Prince and Princess Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Othe ...
- HDU 4675 GCD of Sequence (2013多校7 1010题 数学题)
GCD of Sequence Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)T ...
- HDU 4678 Mine (2013多校8 1003题 博弈)
Mine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- HDU 4630 No Pain No Game(2013多校3 1010题 离线处理+树状数组求最值)
No Pain No Game Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDU 4768 Flyer (2013长春网络赛1010题,二分)
Flyer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- HDU 4747 Mex (2013杭州网络赛1010题,线段树)
Mex Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submis ...
- HDU 4704 Sum (2013多校10,1009题)
Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submi ...
- HDU 4699 Editor (2013多校10,1004题)
Editor Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Su ...
随机推荐
- 64_g5
golang-github-kr-text-devel-0-0.11.git6807e77.f..> 11-Feb-2017 07:48 14250 golang-github-kr-text- ...
- Pylot网站Web服务器性能和负载压力测试-适用Windows可绘制图表
为了能够准确地评估网站服务器对网络流量的承受能力,我们一般会采取模拟网站用户访问,通过不断地增加并发数,延长访问时长,从而最终得出网站Web服务器的性能和负载能力.当然也可以通过Web压力测试,来完善 ...
- HDU-5273
Dylans loves sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
- mac下谷歌chrome浏览器的快捷键
1. 标签页和窗口快捷键 ⌘-N 打开新窗口. ⌘-T 打开新标签页. ⌘-Shift-N 在隐身模式下打开新窗口. 按 ⌘-O,然后选择文件. 在 Chrome 浏览器中打开计算机中的文件. 按住 ...
- CSAPP lab1 datalab-handout(深入了解计算机系统 实验一)
主要涉及计算机中数的表示法: (1)整数: two's complement,即补码表示法 假设用N位bit表示整数w: 其中最左边一位为符号位,符号位为0,表示正数,为1表示负数. (2)浮点数: ...
- 微信小程序 - video组件poster无效 / 视频播放列表
在做有关微信小程序有关视频播放页面的时候,遇到video组件设置poster无效果,然后查了下poster属性:视频封面的图片网络资源地址,如果 controls 属性值为 false 则设置 pos ...
- 微信小程序-如何自定义导航栏(navigationStyle)?
小程序是越来越开放了,微信版本 6.6.0可以自定义导航? 先了解下app.json中window配置navigationStyle属性,即导航栏样式,仅支持 default/custom.custo ...
- GT-----FAQ整理
1.pss0,pss1,这里的序号0和1是什么意思? 说明选的目标调试 App 有至少 2 个进程,先启动的那个进程的 pss 值会被加后缀 0,后启动那个会被加后 缀 1.所有参数前面的“ ...
- Raspberry Pi Finder
这是 meelo 原创的 玩转树莓派 系列文章 作为一名新手,你可能苦恼与如何寻找树莓派的IP地址.要想寻找IP地址,在不同的连接状况下,的方法是不一样的,这在其它教程里有作详细介绍(使用路由器连接树 ...
- loadrunner测试TCP协议服务器性能
loadrunner测试TCP协议服务器性能 . 性能loadrunner测试c 最近对服务器的性能感兴趣,于是开始研究了一阵子loadrunner如何做采用TCP协议交互的服务器的性能测试,对loa ...