题目链接:HDU 5762

题面:

Teacher Bo

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

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
Source
2016 Multi-University Training Contest 3

题意:

问给定的点中,是否存在两对点的曼哈顿距离完全相同,两对点不可以是同一对点。

解题:

其实这题考察的就是暴力,只要抓住差值范围是在0-2*10^5范围内这一点就可以解决。看似n^2遍历,实则最多只会在2*10^5时停下来,用vis数组标记一下即可,如果出现点访问两次即有。

代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#define LL long long
using namespace std;
bool vis[200005];
int x[100005],y[100005];
int main()
{int t,n,m,tmp;bool flag=0;scanf("%d",&t);while(t--){flag=0;scanf("%d%d",&n,&m);memset(vis,0,sizeof(vis));for(int i=0;i<n;i++)scanf("%d%d",&x[i],&y[i]);for(int i=0;i<n;i++){for(int j=i+1;j<n;j++){tmp=abs(x[j]-x[i])+abs(y[j]-y[i]);if(vis[tmp]){flag=1;break;}elsevis[tmp]=1;}if(flag)break;}if(flag)printf("YES\n");else printf("NO\n");}return 0;
}

HDU 5762 Teacher Bo (水题)相关推荐

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

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

  2. hdu 5761 Rower Bo 物理题

    Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Ca ...

  3. HDU 6168 Numbers 思维 水题

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6168 题目描述: 定义数组b是由数组a每两项的和组成的,现在将数组A, B混在一起给你, 筛出数组A ...

  4. HDU 4393 Throw nails [水题]

    题解写了N多方法,我用的是最水的那种.. 起始区间只有(0 <= Fi <= 500),500秒之后排名必然不会变化了..所以,暴力500秒,然后排个序就行了. 1 #include &l ...

  5. HDU 5761 Rower Bo 物理题(积分求时间)

    点击打开链接 题意: 有一个船在(0,a),船头的方向一直指着(0,0)位置,速度是v1,然后有一个水流速度是v2,朝着x轴正半轴方向流. 问你什么时候船到达(0,0)位置 题解: 首先这个题微分方程 ...

  6. HDU - 2091 空心三角形 水题,但是有点坑...

    空心三角形 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  7. hdu 4823 Energy Conversion(水题)

    Energy Conversion Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  8. HDU 5703 Desert 水题 找规律

    HDU 5703 Desert 水题 找规律 已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现 ...

  9. HDU 1033 水题

    题意还真的不好懂,摸索数据就出来了,注意顺时针和逆时针时候的方向变化 /*  * Author:lonelycatcher  * problem:hdu 1033  * Type:水题  */ #in ...

  10. HDU 6264 Super-palindrome(CCPC2017杭州) 水题

    http://acm.hdu.edu.cn/showproblem.php?pid=6264 题目大意:给定字符串TTT,使得该字符串的每个长度为奇数的子串都是回文串,求至少要修改的字符的数量. 思路 ...

最新文章

  1. Spring MVC常用注解说明
  2. python快捷_汇总学习Python必备的42个快捷键,看完收获满满
  3. 类的const和非const成员函数的重载
  4. mybatis学习(6):IntelliJ IDEA 如何创建一个普通的 Java 项目,及创建 Java 文件并运行
  5. LeetCode 1869. 哪种连续子字符串更长
  6. php识别html5,CSS_在IE6/7/8下识别html5标签(让老式浏览器识别html5),识别html5标签: html5添加了许 - phpStudy...
  7. GitHub 的 12 个实用技巧,你 get 了几个?
  8. javascript移动设备触屏事件
  9. 字典生成_数据字典文档自成工具,一键生成,效率倍增
  10. gogs 创建新的仓库
  11. 如何简单的理解TDD与DDT
  12. 单片机课设-电子时钟设计(仿真图、代码全)
  13. html rfftq15.gif,stm32f4中用SD卡存储DCMI的图像
  14. Python-身体质量指数BMI
  15. uvalive 6657 GCD XOR
  16. 拉格朗日乘子法详解(Lagrange multiplier)
  17. linux ora-12162,ORA-12162: TNS:net service name is incorrectly specified
  18. 转:旅游推荐系统的演进
  19. 本地安全策略命令行secedit设置本地账户安全策略
  20. pap认证失败_PPP(CHAP 或 PAP)认证故障排除

热门文章

  1. 美通企业日报 | 山姆开启新一轮价格下调;环旭电子拟4.5亿美金收购欧洲第二大EMS公司...
  2. codeforces1299C Water Balance
  3. ppt太大怎么压缩变小?ppt压缩方法和步骤
  4. 淘宝Fourinone介绍及与Hadoop的性能PK
  5. 计算机技术领域当前的主流技术及其社会需求调查报告
  6. 手游模拟器征途辅助脚本开发
  7. Win8.1 KB2919355更新无法正常安装完成,解决办法?
  8. 计算机访问网络延迟越低越好吗,内存延迟参数是否越低越好
  9. 服务器系统要用GUID还是MBR,分享win10分区格式MBR和GUID有什么区别 教你区分MBR和GUID格式...
  10. 小程序设置page背景图片透明度