Teacher Bo

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1052    Accepted Submission(s): 582

Problem Description
Teacher BoBo is a geography teacher in the school.One day in his class,he marked N
points 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".
 
Input
First line, an integer T
. 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)
.

 
Output
T
lines, each line is "YES" or "NO".
 
Sample Input
2
3 10
1 1
2 2
3 3
4 10
8 8
2 3
3 3
4 4
 
Sample Output
YES
NO
 
Author
绍兴一中
 
Source
 
Recommend
wange2014   |   We have carefully selected several similar problems for you:  5792 5791 5790 5789 5788 
题意:
给出若干组点的坐标,求这中间有没有两组曼哈顿距离相同的坐标。
思路:
题目中X,Y都小于M,就可以用每一种曼哈顿距离作为数组的下标,并把数组标记为1,暴力出数组值为1的那个下标值,就找出了相同的。
 代码:
 #include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<queue>
using namespace std;
struct point
{
int x,y;
};
int main()
{
int n,m,t;
cin>>t;
while(t--)
{
point p[];
int dis[];
cin>>n>>m;
for(int i=;i<n;i++)
{
cin>>p[i].x>>p[i].y;
}
int flag=;
memset(dis,,sizeof(dis));
for(int i=;i<n;i++)
{
for(int j=i+;j<n;j++)
{
int tem=abs(p[i].x-p[j].x)+abs(p[i].y-p[j].y);
if(dis[tem]==)
{
flag=;
break;
}
dis[tem]=;
}
if(flag==)
{
cout<<"YES"<<endl;
break;
}
}
if(flag==) cout<<"NO"<<endl;
}
return ;
}

HDU 5762的更多相关文章

  1. HDU 5762 Teacher Bo (暴力)

    Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...

  2. 【模拟】HDU 5762 Teacher Bo

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 题目大意: 给n个点,坐标范围0~m(n,m<=105),求是否存在2个点对满足哈夫曼距 ...

  3. hdu 5762 Teacher Bo 暴力

    Teacher Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...

  4. HDU 5762 Teacher Bo (鸽笼原理) 2016杭电多校联合第三场

    题目:传送门. 题意:平面上有n个点,问是否存在四个点 (A,B,C,D)(A<B,C<D,A≠CorB≠D)使得AB的横纵坐标差的绝对值的和等于CD的横纵坐标差的绝对值的和,n<1 ...

  5. hdu 5762 Teacher Bo 曼哈顿路径

    Teacher Bo Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tota ...

  6. HDU 5762 Teacher Bo

    Teacher Bo Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tota ...

  7. HDU 5762 Teacher Bo ( 暴力 )

    链接:传送门 题意:给出N个点( Xi , Yi ),和点的最远位置M,询问是否有这样的四个点 (A,B,C,D)(A<B,C<D,A≠CorB≠D) ,AB的曼哈顿路径长度等于CD的曼哈 ...

  8. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  9. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

随机推荐

  1. hash 分区的用途是什么?

    Hash partitioning enables easy partitioning of data that does not lend itself to rangeor list partit ...

  2. 【JDK】电脑上安装多个JDK ,修改JAVA_HOME后没有作用

    电脑上装了 C:\Program Files\Java\jdk1.6.0_43      C:\Program Files\Java\jdk1.7.0_80     C:\Program Files\ ...

  3. 《DSP using MATLAB》示例Example4.12

    上代码: b = [0, 1, 1]; a = [1, -0.9, 0.81]; % [R, p, C] = residuez(b,a); Mp = (abs(p))' Ap = (angle(p)) ...

  4. loopback 02

    数据库连接操作,以mongodb为例 安装loopback-connector-mongodb 修改datasources.json //例子 { "db": { "na ...

  5. 如何定义移动端字体Font-Family?

    1.对于IOS 手机系统,默认中文字体是Heiti SC.默认英文字体是Helvetica.默认数字字体是HelveticaNeue.无微软雅黑字体: 2.对于Android 手机系统,默认中文字体是 ...

  6. pycharm设置主题/默认格式/字体

    1.步骤为:File-->Settings-->Appearance & Behavior-->Appearance-->Theme中就可以选择喜欢的主题 2.一般将文 ...

  7. jquery笔记(遍历)

    祖先: $("selector").parent().css():返回被选元素的直接父元素,并调用css方法. $("selector").parents(). ...

  8. HIT2739 The Chinese Postman Problem(最小费用最大流)

    题目大概说给一张有向图,要从0点出发返回0点且每条边至少都要走过一次,求走的最短路程. 经典的CPP问题,解法就是加边构造出欧拉回路,一个有向图存在欧拉回路的充分必要条件是基图连通且所有点入度等于出度 ...

  9. 来抢你们IT狗的饭碗了

    Java,Html,Css,JavaScript,Jsp啥都不会啊 ,等着我!

  10. ACM Yougth的最大化

    Yougth的最大化 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 Yougth现在有n个物品的重量和价值分别是Wi和Vi,你能帮他从中选出k个物品使得单位重量的价 ...