Teacher Bo HDU
来源:互联网 发布:python math 编辑:程序博客网 时间:2024/05/29 08:28
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)
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, thei -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 Sample Output
题意 :给你n个点,找出两个整数对曼哈顿距离相等。。。
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".
If there exists such tetrad,print "YES",else print "NO".
In each test case,the first line contains two intergers, N, M, means the number of points and the range of the coordinates.
Next N lines, the
23 101 12 23 34 108 82 33 34 4
YESNO
PS :比赛的时候根本不知道曼哈顿距离是什么。。
百度了一下曼哈顿距离
曼哈顿距离就是两个点在标准坐标系上的绝对轴距总和。。
红线代表曼哈顿距离,绿色代表直线距离,而蓝色和黄色代表等价的曼哈顿距离
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;const int M=100010;pair<int,int> iv[M];int ff[4*M];int n,m;int main(){ int f; int t; scanf("%d",&t); while(t--) { f=0;int b; memset(ff,0,sizeof(ff)); scanf("%d%d",&n,&m); for(int i=0;i<n;i++) { scanf("%d%d",&iv[i].first,&iv[i].second); } for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { b=abs(iv[i].first-iv[j].first)+abs(iv[i].second-iv[j].second); if(!ff[b]) { ff[b]=1; } else { f=1; break; } } } if(f==1) printf("YES\n"); else printf("NO\n"); } return 0;}
阅读全文
0 0
- hdu 5762 Teacher Bo
- HDU 5762 Teacher Bo
- HDU 5762 Teacher Bo
- HDU 5762 Teacher Bo
- Teacher Bo HDU
- Teacher Bo HDU
- HDU-5762-Teacher Bo-水题
- 【模拟】HDU 5762 Teacher Bo
- HDU 5762 Teacher Bo (暴力)
- HDU 5762 Teacher Bo(暴力+思维)
- HDU 5762 Teacher Bo (特判后暴力)
- MULti 2016 Teacher Bo(hdu 5763)
- HDU 5762 Teacher Bo (水题)
- hdu 5762 Teacher Bo(暴力美学)
- Teacher Bo
- Teacher Bo
- Teacher Bo
- [HDU 5762] Teacher Bo (鸽巢原理)
- [Leetcode] 135, 136, 137
- Luogu P1825 玉米田迷宫Corn Maze
- 第一只WiFi蠕虫的诞生:完整解析博通WiFi芯片Broadpwn漏洞(含EXP/POC)
- POJ-2533-Longest Ordered Subsequence
- 从两个小例子开始学习flume
- Teacher Bo HDU
- How Many Equations Can You Find
- JavaEE学习笔记分享之初识JSP
- [Python]深拷贝效率
- android 4.0以上横竖屏切换不销毁activity,不重新走生命周期,只调用onConfigurationChanged
- 第 4 章 模型
- 算法——最短路径——Dijkstra算法
- javax.ws.rs.BadRequestException: HTTP 400 Bad Request错误处理
- HDOJ1242 基础宽搜题