日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

hdu5299 Circles Game

發(fā)布時間:2023/11/30 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。