2016 Multi-University Training Contest 3-1011.Teacher Bo,暴力!
Teacher Bo
Time
Limit: 4000/2000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
in the map,the i-th
point is at (Xi,Yi).He
wonders,whether there is a tetrad (A,B,C,D)(A<B,C<D,A≠CorB≠D) such
that the manhattan distance between A and B is equal to the manhattan distance between C and D.
If there exists such tetrad,print "YES",else print "NO".
There are T test
cases.(T≤50)
In each test case,the first line contains two intergers, N, M, means the number of points and the range of the coordinates.(N,M≤105).
Next N lines, the i-th
line shows the coordinate of the i-th
point.(Xi,Yi)(0≤Xi,Yi≤M).
each line is "YES" or "NO".
2
3 10
1 1
2 2
3 3
4 10
8 8
2 3
3 3
4 4
YES
NO
这题实在找不到什么方法做了,只能暴力试试,可是居然卡在曼哈顿路径的概念上了;
我们以为是两点间的距离公示,然后用hypot( ,)WA了两遍,之后两小时一直像睡着了了一样;
早知道百度一下概念,也不会耽误这么多时间,最后两分钟改了求距离那里直接交一发A了;
#include<bits/stdc++.h>
using namespace std;
const int N=100000+10;
struct node
{
int x,y;
} a[N];
int cmp(node a,node b)
{
if(a.x!=b.x) return a.x<b.x;
return a.y<b.y;
}
int main()
{
int t,n,m;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
set<double>m;
for(int i=0; i<n; i++)
scanf("%d%d",&a[i].x,&a[i].y);
sort(a,a+n,cmp);
for(int i=1; i<n; i++)
{
if(a[i].x==a[i-1].x&&a[i].y==a[i-1].y)
{
for(int j=i+1; j<n; j++)
a[j]=a[j-1];
n--;
i--;
}
}
int f=0;
for(int i=0; i<n; i++)
{
if(f) break;
for(int j=i+1; j<n; j++)
{
double dis=abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y);//主要还是概念没搞清,其他地方全正确;
if(m.find(dis)!=m.end())
{
f=1;
break;
}
m.insert(dis);
}
}
if(f) printf("YES\n");
else printf("NO\n");
}
return 0;
}
同!志!仍!需!努!力!
2016 Multi-University Training Contest 3-1011.Teacher Bo,暴力!的更多相关文章
- 2016 Al-Baath University Training Camp Contest-1
2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...
- hdu 5762 Teacher Bo 暴力
Teacher Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...
- 2016 Multi-University Training Contest 5 1011 Two DP
http://acm.hdu.edu.cn/showproblem.php?pid=5791 HDU5791 Two 题意 :两个数组,多少个不连续子串相等 思路: dp[i][j] :a串i结尾,b ...
- 2016 Multi-University Training Contest 3 1011【鸽巢原理】
题解: 坐标(0,m)的话,闭区间,可能一共有多少曼哈顿距离? 2m 但是给一个n,可能存在n(n+1)/2个曼哈顿距离 所以可以用抽屉原理了 当n比抽屉的数量大,直接输出yes 不用计算 那...N ...
- 2016 Al-Baath University Training Camp Contest-1 E
Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...
- 2016 Al-Baath University Training Camp Contest-1 C
Description Rami went back from school and he had an easy homework about bitwise operations (and,or, ...
- 2016 Al-Baath University Training Camp Contest-1 A
Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...
- 2016 Al-Baath University Training Camp Contest-1 J
Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...
- 2016 Al-Baath University Training Camp Contest-1 I
Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...
- 2016 Al-Baath University Training Camp Contest-1 H
Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...
随机推荐
- Create the first sql server 2016 mobile report;创建 第一个 sqlserver 2016 Mobile report
在微软收购了datazen之后,sqlserver2016 集成了mobilereport,mobile report 基于html5,兼容各类主流浏览器,之前ssrs2008 R2中很多chart类 ...
- .NET下集中实现AOP编程的框架
一.Castle 使用这个框架呢,首先是需要安装NuGet包. 先建立一个控制台项目,然后在NuGet中搜索Castle.Windsor,不出意外的话应该能找到如下的包 然后安装,会自动的安装包Cas ...
- github下载下来的C#控制台小游戏[含源码]
早就听说了github是世界最大的源码库,但自己却不是很懂,今天去研究了下,注册了一个帐号,然后在上面搜索了一下C# game,然后发现有许多的游戏. 随意地选择了一个,感觉比较简单,于是就下载了下来 ...
- Linux oraenv Tips
Linux for the Oracle DBA -Customizing the Oracle User's Environment There are many ways to customize ...
- AngularJS ng-repeat下使用ng-model
1 2 3 blue:<input type="radio" value="1" ng-model="selectValue"/> ...
- 桥接模式和php实现
桥接模式(Bridge Pattern): 将抽象部分与它的实现部分分离,使它们都可以独立地变化.它是一种对象结构型模式,又称为柄体(Handle and Body)模式或接口(Interface)模 ...
- [POJ1509]Glass Beads 后缀自动机 最小循环串
题目链接:http://poj.org/problem?id=1509 题目意思就是求循环字符串的最小表示. 我们用字符串S+S建立SAM,然后从root开始走n步,每次尽量选最小的. 由于 SAM ...
- Apache Tomcat 之路(三 部署多个应用)
想要在一台服务器上部署多个web应用的时候有两种部署方式:1.拷贝多个tomcat 服务器,每个服务器启动不同的web应用;2.一个tomcat容器部署多个web应用 两种方式的优缺点:多个tomca ...
- iOS programming UITableView and UITableViewController
iOS programming UITableView and UITableViewController A UITableView displays a single column of dat ...
- 怎么学好XXX
怎么学好数据库是一个比较大题目,数据库不仅仅是写SQL那么简单,即使知道了SQL怎么写,还需要很清楚的知道这条SQL他大概扫描了多少数据,返回多少数据,是否需要创建索引.至于SQL优化是一个比较专业的 ...