Teacher Bo

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

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
 
直接暴力就可以了。为什么可以暴力?因为m最大才100000 那么最多也就有10 0000种曼哈顿距离。座椅答案一定在O(m)的时间内找到。
/* ***********************************************
Author :guanjun
Created Time :2016/7/26 15:10:50
File Name :p311.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 100010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
int n,m;
int x[maxn];
int y[maxn];
map<int,int>mp;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int t;
cin>>t;
while(t--){
cin>>n>>m;
mp.clear();
for(int i=;i<=n;i++){
scanf("%d%d",&x[i],&y[i]);
}
int mark=;
for(int i=;i<=n;i++){
for(int j=i+;j<=n;j++){
int z=abs(x[i]-x[j])+abs(y[i]-y[j]);
if(!mp[z]){
mp[z]=;
}
else{
mark=;
break;
}
}
if(mark)break;
}
if(mark)puts("YES");
else puts("NO");
}
return ;
}

HDU 5762Teacher Bo的更多相关文章

  1. HDU 5753Permutation Bo

    Permutation Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  2. HDU 5752Sqrt Bo

    Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total S ...

  3. hdu Swipe Bo(bfs+状态压缩)错了多次的题

    Swipe Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  4. HDU 5752 Sqrt Bo (数论)

    Sqrt Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f ...

  5. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  6. HDU 5762 Teacher Bo (暴力)

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

  7. HDU 5754 Life Winner Bo (博弈)

    Life Winner Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5754 Description Bo is a "Life W ...

  8. HDU 5752 Sqrt Bo【枚举,大水题】

    Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total S ...

  9. hdu 5761 Rower Bo 物理题

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

随机推荐

  1. c语言中的 strcpy和strncpy字符串函数使用介绍

    1.strcpy函数 函数原型:char *strcpy(char *dst,char const *src)            必须保证dst字符的空间足以保存src字符,否则多余的字符仍然被复 ...

  2. MyBatis 实现分页功能

    MySQL 的分页功能是基于内存的分页(即查出来所有记录,再按起始位置和页面容量取出结果). 案例:①根据用户名(支持模糊查询).用户角色 id 查询用户列表(即根据用户名称或根据用户角色 id 又或 ...

  3. [Python3网络爬虫开发实战] 1.7.2-mitmproxy的安装

    mitmproxy是一个支持HTTP和HTTPS的抓包程序,类似Fiddler.Charles的功能,只不过它通过控制台的形式操作. 此外,mitmproxy还有两个关联组件,一个是mitmdump, ...

  4. linux中PHP安装扩展包(mongodb为例)

    相对于windows中的PHP扩展,只需要在下载相应的dll资源,并且添加配置在php.ini之后即可. 但是在linux安装扩展时,需要进行编译安装. 这里以lnmp一键安装包为例(php.ini位 ...

  5. lucene-5.3.1配置(win7x64)

    lucene下载地址:http://www.us.apache.org/dist/lucene/java/5.3.1/lucene-5.3.1.zip 下载之后解压 控制台应用程序下配置: 找到luc ...

  6. Python中关于使用正则表达式相关的部分笔记

    一点点自己记的笔记,如果各位朋友看不懂,可以在评论区留言,会尽可能快的回复. 所有的知识点全部贴在代码上了,注释也写了. 建议大伙把代码拷到自己的机器上,运行,查看结果,然后,结合注释,再自己稍稍理解 ...

  7. json pickle shelve hashlib collections time

    import json # Json模块提供了四个功能:dumps.dump.loads.load dic = {'k1':'v1','k2':'v2','k3':'v3'} str_dic = js ...

  8. Direct3D 12 创建windows窗口

    之前列出了计算机图形学的计划,现在开始这一阶段的学习,首先是Windows窗口的创建. 创建windows窗口 环境: 1. Visual Studio 2015 新建项目 创建工程项目完成,确定为窗 ...

  9. STM32F407 串口通信实验 第26节 个人笔记

    前言 这篇笔记对应正点原子STM32F407探索者 ,教学视频第26节,网址如下: https://ke.qq.com/webcourse/index.html#cid=279403&term ...

  10. hdu_1398_Square Coins_201404260953

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...