• hdu5299 Circles Game


    题意是这样。给出非常多圆,要么两两相离,要么包括,若删掉一个圆,那被他包括的都要删除,若某人没有圆给他删,那么他就赢了。


    。。。知道树上博弈的话。就非常easy。

    。。不知道的话。这确实是个神题……


    按半径上升排序,从左往右扫。i扫到第一个j能够包括它的圆,建立j到i的连边,然后break


    这样就建立好了一棵树,之后知道这个就非常easy了。。。

    树的删边游戏
    规则例如以下:
     给出一个有 N 个点的树,有一个点作为树的根节点。
     游戏者轮流从树中删去边,删去一条边后,不与根节点相连的
    部分将被移走。
     谁无路可走谁输。


    我们有例如以下定理:
    [定理]
    叶子节点的 SG 值为 0;

    中间节点的 SG 值为它的全部子节点的 SG 值加 1 后的异或和。

    当然啦,像我这样暴力的写法。交c++会超时

    #include<map>
    #include<string>
    #include<cstring>
    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    #include<queue>
    #include<vector>
    #include<iostream>
    #include<algorithm>
    #include<bitset>
    #include<climits>
    #include<list>
    #include<iomanip>
    #include<stack>
    #include<set>
    using namespace std;
    typedef long long ll;
    struct Point
    {
    	int x,y,r;
    }point[20010];
    bool cmp(Point a,Point b)
    {
    	return a.r<b.r;
    }
    struct Edge
    {
    	int to,next;
    }edge[20010];
    int head[20010],tail;
    void add(int from,int to)
    {
    	edge[tail].to=to;
    	edge[tail].next=head[from];
    	head[from]=tail++;
    }
    int dfs(int from)
    {
    	int ans=0;
    	for(int i=head[from];i!=-1;i=edge[i].next)
    		ans^=dfs(edge[i].to)+1;
    	return ans;
    }
    int main()
    {
    	int T;
    	scanf("%d",&T);
    	while(T--)
    	{
    		int n;
    		scanf("%d",&n);
    		for(int i=0;i<n;i++)
    			scanf("%d%d%d",&point[i].x,&point[i].y,&point[i].r);
    		sort(point,point+n,cmp);
    		tail=0;
    		memset(head,-1,sizeof(head));
    		for(int i=0;i<n;i++)
    		{
    			bool flag=0;
    			for(int j=i+1;j<n;j++)
    				if(ll(point[j].r*point[j].r)>ll(point[i].x-point[j].x)*(point[i].x-point[j].x)+(point[i].y-point[j].y)*(point[i].y-point[j].y))
    				{
    					flag=1;
    					add(j,i);
    					break;
    				}
    			if(!flag)
    				add(n,i);
    		}
    		if(dfs(n)!=0)
    			puts("Alice");
    		else
    			puts("Bob");
    	}
    }

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 593    Accepted Submission(s): 164


    Problem Description
    There are n circles on a infinitely large table.With every two circle, either one contains another or isolates from the other.They are never crossed nor tangent.
    Alice and Bob are playing a game concerning these circles.They take turn to play,Alice goes first:
    1、Pick out a certain circle A,then delete A and every circle that is inside of A.
    2、Failling to find a deletable circle within one round will lost the game.
    Now,Alice and Bob are both smart guys,who will win the game,output the winner's name.
     

    Input
    The first line include a positive integer T<=20,indicating the total group number of the statistic.
    As for the following T groups of statistic,the first line of every group must include a positive integer n to define the number of the circles.
    And the following lines,each line consists of 3 integers x,y and r,stating the coordinate of the circle center and radius of the circle respectively.
    n≤20000,|x|≤20000。|y|≤20000,r≤20000。
     

    Output
    If Alice won,output “Alice”,else output “Bob”
     

    Sample Input
    2 1 0 0 1 6 -100 0 90 -50 0 1 -20 0 1 100 0 90 47 0 1 23 0 1
     

    Sample Output
    Alice Bob
     

    Author
    FZUACM
     

    Source
     

  • 相关阅读:
    常见存储过程分页PK赛——简单测试分析常见存储过程分页速度
    简单的ASP.NET无刷新分页
    程序员45个好习惯
    手机应用兼职开发平台,欢迎有识之士参加...
    DotNetRemoting分布式安全部署(整理+原创)
    刚刚整理的截获SQL错误代码弹出提示信息类.
    485modbus通讯协议
    485通信
    ucoss在stm32上的移植
    使用OFFICE组件出问题环境配置
  • 原文地址:https://www.cnblogs.com/yangykaifa/p/6897097.html
Copyright © 2020-2023  润新知