hdu 4664 Triangulation 博弈论。。。。我把这题称作是花样打表。。受不了了,各种坑

原创 2015年02月28日 21:25:32

Triangulation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 633    Accepted Submission(s): 248


Problem Description
There are n points in a plane, and they form a convex set.

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.
 

Input
First line, number of test cases, T.
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.
 

Output
T lines. If Carol wins the corresponding game, print 'Carol' (without quotes;) otherwise, print 'Dave' (without quotes.)
 

Sample Input
2 1 2 2 2 2
 

Sample Output
Carol Dave
 
这题意说的很笼统,,给你们一篇博客看吧,http://www.xuebuyuan.com/2010248.html
说的很详细的
这题的规律还真不好找,,出这题的真特么蛋疼。
前100个有几个数总是操蛋的不等于,,所以规律从后一百个找,比较方便和正确。
SG打表找规律代码(不是杭电提交代码):
#include <stdio.h>
#include <string.h>
#define MAX 150
int sg[MAX] ;
int main()
{
	sg[2] = 1 ;
	bool visited[MAX] ;
	for(int i = 0 ; i < MAX ; ++i)
	{
		memset(visited,false,sizeof(visited)) ;
		for(int j = 0 ; j <= i-2 ; ++j)
		{
			visited[sg[i-2-j]^sg[j]] = true ;
		}
		for(int j = 0 ; j <= MAX ; ++j)
		{
			if(!visited[j])
			{
				sg[i] = j;
				printf("%d,",j);
				break ;
			}
		}
	}
	return 0 ;
}




下面是我的花样打表代码(杭电提交代码):

#include <stdio.h>
int sg1[]={0,0,1,1,2,0,3,1,1,0,3,3,2,2,4,0,5,2,2,3,3,0,1,1,3,0,2,1,1,0,4,5,2,7,4,0,1,1,2,0,
			3,1,1,0,3,3,2,2,4,4,5,5,2,3,3,0,1,1,3,0,2,1,1,0,4,5,3,7,4,8,1,1,2,0,3,1,1,0,3,3,
			2,2,4,4,5,5,9,3,3,0,1,1,3,0,2,1,1,0,4,5} ;
int sg2[] = {3,7,4,8,1,1,2,0,3,1,1,0,3,3,2,2,4,4,5,5,9,3,3,0,1,1,3,0,2,1,1,0,4,5};
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		int ans = 0 ;
		for(int i = 0 ; i < n ; ++i)
		{
			int temp ;
			scanf("%d",&temp);
			if(temp>=100)
			{
				ans ^= sg2[(temp-100)%34] ;
			}
			else
			{
				ans ^= sg1[temp] ;
			}
		}
		if(ans)
		{
			puts("Carol") ;
		}
		else
		{
			puts("Dave");
		}
	}
	
	return 0 ;
}

与君共勉

相关文章推荐

HDU4664 Triangulation sg函数

题目链接:HDU4664 Triangulation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768...

hdu 4664 Triangulation/杭电多校2013第六场1010, SG定理+找规律

#include #include #include using namespace std; #define maxn 1000001 __int64 sg[300]={0,0,1,1,2,0...

hdu 3032 Nim or not Nim? 博弈论,,,网上搜的题解让我大开眼界,原来还可以这样A题

Problem Description Nim is a two-player mathematic game of strategy in which players take turns remo...

HDU 1847 Good Luck in CET-4 Everybody!(博弈论入门题)

Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K...
  • lwgkzl
  • lwgkzl
  • 2017年02月12日 19:20
  • 107

hdu 2177 取(2堆)石子游戏 博弈论,,威佐夫博奕 ,提高题,不过测试数据奇水无比

Problem Description 有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同...

hdu 1455 Sticks DFS 又是一个花样剪枝 ,累觉不爱

Problem Description George took sticks of the same length and cut them randomly until all parts beca...

Codeforces #848C: String Reconstruction 题解之花样虐题

显然的是,没有被赋过值的点,赋上a能保证字典序最小 不论何种方法,最终的目的是不要让一个位置被重复赋值 这题最重要的注意点是,区间可以从1e6开始,长度是1e6,所以字符串数组ans要开到...

hdu 1079 Calendar Game 博弈论

Calendar GameTime Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota...

hdu2149 -- Public Sale(博弈论)

Public Sale Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota...

hdu 4111 Alice and Bob 博弈论 sg函数

Problem Description Alice and Bob are very smart guys and they like to play all kinds of games in t...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:hdu 4664 Triangulation 博弈论。。。。我把这题称作是花样打表。。受不了了,各种坑
举报原因:
原因补充:

(最多只允许输入30个字)