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的那个下标值,就找出了相同的。
 代码:
  1. #include<iostream>
  2. #include<string>
  3. #include<cstdio>
  4. #include<cmath>
  5. #include<cstring>
  6. #include<algorithm>
  7. #include<vector>
  8. #include<iomanip>
  9. #include<queue>
  10. using namespace std;
  11. struct point
  12. {
  13. int x,y;
  14. };
  15. int main()
  16. {
  17. int n,m,t;
  18. cin>>t;
  19. while(t--)
  20. {
  21. point p[];
  22. int dis[];
  23. cin>>n>>m;
  24. for(int i=;i<n;i++)
  25. {
  26. cin>>p[i].x>>p[i].y;
  27. }
  28. int flag=;
  29. memset(dis,,sizeof(dis));
  30. for(int i=;i<n;i++)
  31. {
  32. for(int j=i+;j<n;j++)
  33. {
  34. int tem=abs(p[i].x-p[j].x)+abs(p[i].y-p[j].y);
  35. if(dis[tem]==)
  36. {
  37. flag=;
  38. break;
  39. }
  40. dis[tem]=;
  41. }
  42. if(flag==)
  43. {
  44. cout<<"YES"<<endl;
  45. break;
  46. }
  47. }
  48. if(flag==) cout<<"NO"<<endl;
  49. }
  50. return ;
  51. }

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. jfreeChart柱状图各属性详细设置

    一. 下载与环境配置 此最新版本为 1.0.13 解压jfreechart-1.0.13.zip 将lib目录下的jfreechart-1.0.13.jar .jcommon-1.0.16.jar 复 ...

  2. (转载)Bash 中的特殊字符大全

    转自:https://linux.cn/article-5657-1.html Linux下无论如何都是要用到shell命令的,在Shell的实际使用中,有编程经验的很容易上手,但稍微有难度的是she ...

  3. SQLServer 本地移动发布/订阅/分发数据库文件并更改逻辑名称和物理文件名

    -------------------------------------------------------------------------------------------------- - ...

  4. Hibernate的核心API

    Configuration:负责管理Hibernate的配置信息 1.加载核心配置文件 核心配置有两种: hibernate.properties 加载:Configuration configura ...

  5. 【hibernate criteria】hibernate中criteria的完整用法 转

    ---恢复内容开始--- 转自:http://www.360doc.com/content/090313/10/26262_2794855.html 1.Criteria Hibernate 设计了 ...

  6. bat 炸弹升级

    转自:http://digi.163.com/15/0320/06/AL4LP0QD0016192R.html 第1页:什么是批处理炸弹? 最近网上流传一个叫做<大哥别杀我>视频纷纷遭到网 ...

  7. AchartEngine 的学习

    第一步:我使用的事AchartEngine 1.1.0 的包.大家要先下在这个包,放到项目中,创建一个lib文件夹.然后倒金项目中去.然后再AndroidManifest.xml 中需要注册一下代码是 ...

  8. ROC曲线绘制

    ROC 曲线绘制 个人的浅显理解:1.ROC曲线必须是针对连续值输入的,通过选定不同的阈值而得到光滑而且连续的ROC曲线,故通常应用于Saliency算法评价中,因为可以选定0~255中任意的值进行阈 ...

  9. window系统查看端口被哪个进程占用了

    C:\netstat -aon|findstr 8080TCP 127.0.0.1:80 0.0.0.0:0 LISTENING 2448端口被进程号为2448的进程占用,继续执行下面命令:C:\ta ...

  10. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...