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");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

轉載于:https://www.cnblogs.com/yangykaifa/p/6897097.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/392703.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/392703.shtml
英文地址,請注明出處:http://en.pswp.cn/news/392703.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

leetcode 1356. 根據數字二進制下 1 的數目排序(排序)

給你一個整數數組 arr 。請你將數組中的元素按照其二進制表示中數字 1 的數目升序排序。 如果存在多個數字二進制中 1 的數目相同&#xff0c;則必須將它們按照數值大小升序排列。 請你返回排序后的數組。 示例 1&#xff1a; 輸入&#xff1a;arr [0,1,2,3,4,5,6,7,8] 輸…

oracle java認證_如何通過Oracle的Java認證-開發人員實用指南

oracle java認證by javinpaul由javinpaul 如何通過Oracle的Java認證-開發人員實用指南 (How to Pass Oracle’s Java Certifications — a Practical Guide for Developers) A Java certification is highly regarded in the IT Industry and provides a Java developer with …

Oracle中exists與in的效率探討

in 與 exist 的語法比較&#xff1a; select from 數據表 t where t.x in (...) 括號內可以是符合t.x字段類型的值集合&#xff0c;如(1,2,3)&#xff0c;但如果t.x是number類型的時候&#xff0c;似乎這樣的寫法會出問題&#xff1b;也可以是通 過另外的sele…

log日志輪轉--logrotate

服務器上的日志包括系統日志和服務日志每天都會產生n多log,好多人會自己寫腳本來進行日志的切割、壓縮等&#xff0c;而忽略了系統自帶的服務--logrotate。 簡介 logrotate是個十分有用的工具&#xff0c;它可以自動對日志進行截斷&#xff08;或輪循&#xff09;、壓縮以及刪除…

2個字段并在一次插入一個字段里面_elasticsearch外用與內觀(二)-當插入文檔時,elasticsearch都在做什么...

Previous: elasticsearch外用與內觀(一)-常用功能與使用方法 在了解了es的基本用法之后&#xff0c;我們再來看看當插入文檔數據時&#xff0c;elasticsearch都在做什么。首先&#xff0c;es的索引只是一個邏輯概念&#xff0c;實際上是由一個個物理分片組成的,每個分片就是一個…

學習Spring Data JPA

簡介 Spring Data 是spring的一個子項目&#xff0c;在官網上是這樣解釋的&#xff1a; Spring Data 是為數據訪問提供一種熟悉且一致的基于Spring的編程模型&#xff0c;同時仍然保留底層數據存儲的特??殊特性。它可以輕松使用數據訪問技術&#xff0c;可以訪問關系和非關系…

azure多功能成像好用嗎_Azure持久功能簡介:模式和最佳實踐

azure多功能成像好用嗎Authored with Steef-Jan Wiggers at Microsoft Azure由Microsoft Azure的Steef-Jan Wiggers撰寫 With Durable Functions, you can program a workflow and instantiate tasks in sequential or parallel order, or you can build a watch or support a…

leetcode 327. 區間和的個數(treemap)

給定一個整數數組 nums&#xff0c;返回區間和在 [lower, upper] 之間的個數&#xff0c;包含 lower 和 upper。 區間和 S(i, j) 表示在 nums 中&#xff0c;位置從 i 到 j 的元素之和&#xff0c;包含 i 和 j (i ≤ j)。 說明: 最直觀的算法復雜度是 O(n2) &#xff0c;請在此…

常用的工具函數

得到兩個數組的并集, 兩個數組的元素為數值或字符串//tools.js export const getUnion (arr1, arr2) > {return Array.from(new Set([...arr1, ...arr2])) }//調用頁面 import { getUnion } from /libs/toolsthis.getUnion getUnion([1,2,3,5],[1,4,6]) //(6) [1, 2, 3,…

git 常用commands(轉)

常用 Git 命令清單 作者&#xff1a; 阮一峰 日期&#xff1a; 2015年12月 9日 我每天使用 Git &#xff0c;但是很多命令記不住。 一般來說&#xff0c;日常使用只要記住下圖6個命令&#xff0c;就可以了。但是熟練使用&#xff0c;恐怕要記住60&#xff5e;100個命令。 下面是…

Win2003磁盤分區調整

引用如下&#xff1a; 可能大家都知道&#xff0c;在Windows Server 2003下&#xff0c;普通版本的分區魔術師是無法運行的&#xff0c;而Windows內置的命令行工具Diskpart則能勝任分區魔術師的大部分工作&#xff0c;它的功能非常強大。輸入Diskpart后&#xff0c;將顯示如圖所…

檢查集群狀態命令_輕松管理Kubernetes集群的7個工具

Kubernetes正在不斷加快在云原生環境的應用&#xff0c;但如何以統一、安全的方式對運行于任何地方的Kubernetes集群進行管理面臨著挑戰&#xff0c;而有效的管理工具能夠大大降低管理的難度。K9sk9s是基于終端的資源儀表板。它只有一個命令行界面。無論在Kubernetes儀表板Web …

leetcode 122. 買賣股票的最佳時機 II(貪心算法)

給定一個數組&#xff0c;它的第 i 個元素是一支給定股票第 i 天的價格。 設計一個算法來計算你所能獲取的最大利潤。你可以盡可能地完成更多的交易&#xff08;多次買賣一支股票&#xff09;。 注意&#xff1a;你不能同時參與多筆交易&#xff08;你必須在再次購買前出售掉…

前端繪制繪制圖表_繪制圖表(第2頁):JavaScript圖表庫的比較

前端繪制繪制圖表by Mandi Cai蔡曼迪 繪制圖表(第2頁)&#xff1a;JavaScript圖表庫的比較 (Charting the waters (pt. 2): a comparison of JavaScript charting libraries) 深入研究D3.js&#xff0c;Dygraphs&#xff0c;Chart.js和Google Charts (A deep dive into D3.js,…

python 3.6.5 pip_在Windows 10 + Python 3.6.5 中用 pip 安裝最新版 TensorFlow v1.8 for GPU

聲明什么cuDNN之類的安裝&#xff0c;應該是毫無難度的&#xff0c;按照官網的教程來即可&#xff0c;除非。。。像我一樣踩了狗屎運。咳咳&#xff0c;這些問題不是本文的關鍵。本文的關鍵是解決pip安裝tensorflow gpu版的問題。安裝環境操作系統&#xff1a;64位的Windows 10…

模板進階——模板實參推斷

一、關鍵點 模板實參&#xff1a;模板參數T的實例類型&#xff0c;如int、string等 模板實參推斷&#xff1a;從函數實參來確定模板實參的過程 模板類型參數與類型轉換&#xff1a;const的轉換、數組/函數到指針的轉換 顯式模板實參&#xff1a;當模板參數類型并未出現在函數參…

leetcode 973. 最接近原點的 K 個點(排序)

我們有一個由平面上的點組成的列表 points。需要從中找出 K 個距離原點 (0, 0) 最近的點。 &#xff08;這里&#xff0c;平面上兩點之間的距離是歐幾里德距離。&#xff09; 你可以按任何順序返回答案。除了點坐標的順序之外&#xff0c;答案確保是唯一的。 示例 1&#xf…

ios 打開揚聲器

[[UIDevice currentDevice] setProximityMonitoringEnabled:YES]; AVAudioSession *audioSession [AVAudioSession sharedInstance]; //默認情況下揚聲器播放 [audioSession setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthe…

sqlserver 批量處理數據

目前我覺得有兩種方法可以用作批量數據的處理&#xff0c;也算比較靠譜的吧&#xff1a;sqlbulkcopy 和利用表值函數。 1.sqlbulkcopy是dotnet中的一個用來處理大批量插入數據的&#xff0c;具體用法如下&#xff1a; using (SqlConnection conSave new SqlConnection(Config.…

區塊鏈編程語言_區塊鏈開發中使用的最受歡迎的編程語言

區塊鏈編程語言by Michael Draper通過邁克爾德雷珀(Michael Draper) We’re currently in the midst of a new burgeoning industry with blockchain development.我們目前正處于區塊鏈開發的新興行業中。 Blockchain technology is very much in a nascent stage, however t…