hdu5299 Circles Game
生活随笔
收集整理的這篇文章主要介紹了
hdu5299 Circles Game
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
題意是這樣。給出非常多圓,要么兩兩相離,要么包括,若刪掉一個圓,那被他包括的都要刪除,若某人沒有圓給他刪,那么他就贏了。
。。。知道樹上博弈的話。就非常easy。
。。不知道的話。這確實是個神題……
按半徑上升排序,從左往右掃。i掃到第一個j能夠包括它的圓,建立j到i的連邊,然后break
這樣就建立好了一棵樹,之后知道這個就非常easy了。。。
樹的刪邊游戲
規(guī)則例如以下:
? 給出一個有 N 個點的樹,有一個點作為樹的根節(jié)點。
? 游戲者輪流從樹中刪去邊,刪去一條邊后,不與根節(jié)點相連的
部分將被移走。
? 誰無路可走誰輸。
我們有例如以下定理:
[定理]
葉子節(jié)點的 SG 值為 0;
中間節(jié)點的 SG 值為它的全部子節(jié)點的 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");elseputs("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 2015 Multi-University Training Contest 1
轉(zhuǎn)載于:https://www.cnblogs.com/yangykaifa/p/6897097.html
總結
以上是生活随笔為你收集整理的hdu5299 Circles Game的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: array_walk与array_map
- 下一篇: git 常用commands(转)