https://vjudge.net/contest/388843#problem/G

Notice:Don't output extra spaces at the end of one line.

Dodo bird and ddd are playing a stone game on a 2-d plane. There are $n$ points on the plane where they can put the stone. The rule is as follows:

- Before the game start, The stone is at the first point.
- Dodo and ddd move the stone in turn, Dodo moves first.
- In the first move, the player can move the stone to any point except the first point.
- Starting from the second move, assume the stone is currently at point $x$, and the distance of the stone traveled in the last move is $d$. The player can move the stone to a point $y$ if and only if $\text{distance(x,y)} > d$ and point $y$ has never been visited before.
- If a player cannot make a move, he loses the game.

Please determine who will win the game if both player use the best strategy.

InputThe first line contains an integer $T(1 \leq T \leq 100)$, indicating the number of test cases.

Each test case contains several lines. The first line contains an integer $n(2 \leq n \leq 2000)$, indicating the number of points. Next $n$ lines, each line contains two integers $x_i, y_i(-10^9 \leq x, y \leq 10^9)$, indicating the coordinate of the i-th point.

It is guaranteed that there are at most 12 test cases with $n > 500$.
OutputFor each test case, If Dodo can win the game, print "YES". Otherwise, print "NO".Sample Input

2
5
1 1
0 0
2 0
0 2
2 2
4
1 1
0 0
0 2
2 2

Sample Output

NO
YES

Sponsor

题意:
A,B轮流走,每次走的距离比上一次大。走过的点不能再走,不能走的人输,问先手是否必胜。

思路:

参考 https://blog.csdn.net/tomjobs/article/details/107947511

最后走到最远距离的一对点,一人先走到这些点中行动,另一人就不能再行动了。

最多只剩下一个最远点 偶数先手胜

最后只剩下一个点且为点1,1必败。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include <vector>
#include <iterator>
#include <utility>
#include <sstream>
#include <limits>
#include <numeric>
#include <functional>
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
#define debug(x) cout<<"debug:"<<#x<<" = "<<x<<endl; #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef char ch;
typedef double db; const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=2007;
//const int maxm=100+10;
const int N=1e6+10;
const int mod=1e9+7; struct node
{
ll x , y , d;
};
node A[maxm];
node Path[maxm*maxm]; int v[maxm] = {0}; int cmp(node x,node y)
{
return x.d < y.d;//递增
}
ll D(int i,int j)
{
int ans = (A[i].x-A[j].x)*(A[i].x-A[j].x)+(A[i].y-A[j].y)*(A[i].y-A[j].y);
return ans;
}
int main() {
int T = 0;
cin >> T; while(T--)
{
int n = 0;
cin >> n;
for(int i = 0;i<n;i++)
{
cin >> A[i+1].x >> A[i+1].y;
v[i] = 0;
}
int L = 0;
for(int i = 0;i<n;i++)
{
for(int j = i;j < n;j++)
{
L += 1;
Path[L].x = i+1;
Path[L].y = j+1;
Path[L].d = D(i+1,j+1);
}
}
sort(Path+1,Path+1+L,cmp); int X = 0;
int Y = 0;
for(int i = 0;i<L;i++)
{
X = Path[L-i].x;
Y = Path[L-i].y;
if(v[X] || v[Y])
{
continue;
}
else
{
n = n - 2;
v[X] = 1;
v[Y] = 1;
}
} if(n == 0)
{
cout << "YES" <<endl;
}
if(n == 1)
{
if(v[1]) cout << "YES" <<endl;
}
if(n !=0 && n != 1) cout << "NO" <<endl;
}
return 0;
}

  

G - Game的更多相关文章

  1. Storyboards Tutorial 03

    这一节主要介绍segues,static table view cells 和 Add Player screen 以及 a game picker screen. Introducing Segue ...

  2. 文件图标SVG

    ​<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink ...

  3. [转]Linux下g++编译与使用静态库(.a)和动态库(.os) (+修正与解释)

    在windows环境下,我们通常在IDE如VS的工程中开发C++项目,对于生成和使用静态库(*.lib)与动态库(*.dll)可能都已经比较熟悉,但是,在linux环境下,则是另一套模式,对应的静态库 ...

  4. CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)

    ---恢复内容开始--- CentOS 6.6 升级GCC G++ (当前最新GCC/G++版本为v6.1.0) 没有便捷方式, yum update....   yum install 或者 添加y ...

  5. Linux deepin 下sublimes配置g++ openGL

    参考 :http://blog.csdn.net/u010129448/article/details/47754623 ubuntu 下gnome只要将代码中deepin-terminal改为gno ...

  6. [翻译svg教程]svg 中的g元素

    svg 中的<g>元素用来组织svg元素.如果一组svg元素被g元素包裹了,你可以通过对g元素进行变换(transform),被g元素包裹的元素也将被变换,就好这些被svg包裹的元素是一个 ...

  7. 软件工程:黄金G点小游戏1.0

    我们要做的是黄金G点小游戏: N个同学(N通常大于10),每人写一个0~100之间的有理数 (不包括0或100),交给裁判,裁判算出所有数字的平均值,然后乘以0.618(所谓黄金分割常数),得到G值. ...

  8. 2016huasacm暑假集训训练五 G - 湫湫系列故事——减肥记I

    题目链接:http://acm.hust.edu.cn/vjudge/contest/126708#problem/G 这是一个01背包的模板题 AC代码: #include<stdio.h&g ...

  9. 毫秒级的时间处理上G的图片(生成缩略图)

    测试环境: 测试图片(30M): 测试计时方法: Stopwatch sw1 = new Stopwatch(); sw1.Start(); //TODO...... sw1.Stop(); stri ...

  10. g++编译流程

    测试程序test.cpp如下所示: #include <iostream> using namespace std; #define MAX 9 int main() { //just f ...

随机推荐

  1. 深度系统deepin/uos动态壁纸

    深度系统deepin下使用动态壁纸 演示视频: https://www.bilibili.com/video/BV1bB4y1c7Fq 最新版本(2022/2/9): uos版本 : https:// ...

  2. ChatMoney让我重新找到创作灵感

    本文由 ChatMoney团队出品 今天是 2024 年 6月 19 日,星期三,哈喽大家好,我是一名乡野自媒体创作者小麦,基本上每天都会在自媒体的海洋中创作.重复着创作.创新.写稿.改稿.学习.复盘 ...

  3. linux搭建natapp内网穿透服务器

    参考教程:window版本 https://www.jianshu.com/p/8897106c8d3dlinux版本 https://natapp.cn/article/natapp_newbie相 ...

  4. .Net Web API 001 新建Net Web API工程

    1.新建工程 打开VS2022,点击新建项目,弹出创建新项目对话框,然后在项目模板处,选择C#.所有平台以及WebAPI,如下图所示. 选择了下面的唯一模板,点击下一步,设置项目的名称.保存路径等.如 ...

  5. MongoDB入门实战教程(12)

    MongoDB在4.2版本开始全面支持了多文档事务,这也让MongoDB可以作为OLTP的选项之一,本篇我们就来学习一下MongoDB的多文档事务. 1 ACID支持程度 谈到事务,就不得不提经典的A ...

  6. 分时间段(年份或月份)统计,没有数字补0 Java(替代 MYSQL) 做法

    需求如下~ 输入年份,表格第一行 1-12 月 输入年份和月份  表格第一行 1--31  具体天数 表格第二行就是统计数量,没有补0. 看完首先想到MYSQL查询出连续一段时间和数量,没有 就为0. ...

  7. AWTK项目编译问题整理(1)

    三方库组织 公司的项目初步三方库路径组织是这样,awtk-widget开头的是awtk的自定义控件,无源码的二进制库放在sourceless这个文件夹: ./3rd   ├── awtk-widget ...

  8. 京东携手HarmonyOS SDK首发家电AR高精摆放功能

    在电商行业的演进中,商品的呈现方式不断升级:从文字.图片到视频,再到如今逐渐兴起的3D与AR技术.作为XR应用探索的先行者,京东正站在这场体验革新的最前沿,不断突破商品展示的边界,致力于通过创新技术让 ...

  9. Spark知识点汇总

    一.Spark架构设计 二.Spark常用算子 tips1: 数据处理的生命周期tips2: repartition vs coalesce区别: 可以使用 repartition 算子随意调整(提升 ...

  10. Wordpress设置必须登录才能查看内容

    参考文章地址 我是一个不会编程的小白,在网上查了好多篇的文章都没有实现这个功能.都是在改完php的代码后,网站就报废了.后来我还是求助了万能的谷歌,找了这篇文章. 上代码.大概猜测了一下,就是判断你现 ...