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 ...
随机推荐
- sk_buff结构
sk_buff结构用来描述已接收或者待发送的数据报文信息:skb在不同网络协议层之间传递,可被用于不同网络协议,如二层的mac或其他链路层协议,三层的ip,四层的tcp或者udp协议,其中某些成员变量 ...
- centos_7.1.1503_src_7
http://vault.centos.org/7.1.1503/os/Source/SPackages/ tex-fonts-hebrew-0.1-21.el7.src.rpm 05-Jul-201 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha's staff 思维
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 题意:在笛卡尔坐标系下,画一个面积至少为 n 的简单多边形,每次只能画一条边或者一个格子的对角 ...
- 阿里云ECS的使用
一.阿里云ECS的使用 1.Linux CentOS Ubuntu Readhat 2.远程登录 xshell 远程登录 winScp 远程文件操作 3.Linux命令 cd 目录名 ls . ls ...
- python_day2学习笔记
基本数据类型 1.数字 int(整型) 在32位机器上,整数的位数为32位,取值范围为-2**31-2**31-1,即-2147483648-2147483647 在64位系统上,整数的位数为64位, ...
- nginx中使用perl模块
转载自:http://www.netingcn.com/nginx-perl.html 如果对于一个绝大部分内容是静态的网站,只有极少数的地方需要动态显示,碰巧你又了解一点perl知识,那么nginx ...
- 将对象转换为JSON字符串
将对象转换为JSON串: 方案一: 可以通过json-lib工具jar包进行转化:在www.json.org官网下载jar包. 方案二: 通过ObjectMapper对象进行转换 需要引入相应的jar ...
- 图片乱码问题 解决方法 php
两个开发者都是下载同一个项目的git代码,但到本地环境,一个可以正常显示图片验证码,一个不行,找个半天开始以为环境问题 找了半天 不是 很多没说到重点 其实不只是当前文件格式问题 也要考虑其他调用文件 ...
- React Native 0.56.1初始化项目运行出现错误(Module `AccessibilityInfo` does not exist in the Haste module map)
当使用react-native init myApp初始化项目时,出现以下错误 出现以上错误的原因是因为0.56.1版本初始化项目就有问题,请见 https://github.com/facebook ...
- 160. Intersection of Two Linked Lists【Easy】【求两个单链表的第一个交点】
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...