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.mzph.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…