题目链接:

Teacher Bo

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

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
 
题意:
问这些点中是否有两对点他们之间的曼哈顿距离相同;
 
思路:
 
曼哈顿距离最多2*10^5;所以可以暴力找到所有的距离,当时还傻乎乎的想了半天;
 
AC代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef unsigned long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e5+10;
const int maxn=1000+10;
const double eps=1e-8; int n,m,vis[2*N]; struct node
{
int x,y;
}po[N];
int check()
{
For(i,1,n)
{
For(j,i+1,n)
{
int dis=abs(po[i].x-po[j].x)+abs(po[i].y-po[j].y);
if(vis[dis])return 1;
vis[dis]=1;
}
}
return 0;
}
int main()
{
int t;
read(t);
while(t--)
{
read(n);read(m);
For(i,0,2*m+1)vis[i]=0;
For(i,1,n)
{
read(po[i].x);read(po[i].y);
}
if(check())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 5762 Teacher Bo 暴力

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

  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 曼哈顿路径

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

  5. 【模拟】HDU 5762 Teacher Bo

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

  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. HDU 5776 sum(抽屉原理)

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=5776 Problem Description Given a sequence, you're ask ...

  9. hdu 1205 吃糖果 (抽屉原理<鸽笼原理>)

    吃糖果Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submissi ...

随机推荐

  1. Geoserver跨域请求设置

    使用OpenLayers请求GeoServer发布的WFS服务时,如果不是相同的域可能会出现如下问题. 已拦截跨源请求:同源策略禁止读取位于 http://localhost:8080/geoserv ...

  2. Android传统View动画与Property动画基础及比较

    前言:关于动画方面的知识也整理一段时间了,如题,这篇文章简单的介绍了View和Property动画的概念,如何在项目中创建资源文件,以及如何在代码中使用它们,本次整理动画的重点放在了Property动 ...

  3. STL源代码剖析 容器 stl_deque.h

    本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie deque ---------------------------------------- ...

  4. 理解MySql事务隔离机制、锁以及各种锁协议

    一直以来对数据库的事务隔离机制的理解总是停留在表面,其内容也是看一遍忘一边.这两天决定从原理上理解它,整理成自己的知识.查阅资料的过程中发现好多零碎的概念假设串起来足够写一本书,所以在这里给自己梳理一 ...

  5. 【凯子哥带你夯实应用层】使用ActionProvider实现子菜单时遇到的一个坑

    转载请注明出处:http://blog.csdn.net/zhaokaiqiang1992 近期在重温Android基础.在看到ActionProvider的时候遇到一个坑.分享到大家,避免入坑. 首 ...

  6. SpringBoot学习之验证信息国际化

    以登录为例: 1.controller的登录方法: @RequestMapping("/SSOAuth/login") @ResponseBody public ResponseV ...

  7. Hadoop 服务器配置的副本数量 管不了客户端

    副本数由客户端的参数dfs.replication决定(优先级: conf.set > 自定义配置文件 > jar包中的hdfs-default.xml)如果前两个都没有,就用最后一个ja ...

  8. <转>关于 error LNK2019:无法解析的外部符号 ,该符号在函数**中被引用的思考

    错误提示信息摘抄如下: ---------------------------------------------------------------------------------------- ...

  9. POJ 2480 Longge&#39;s problem 积性函数

    题目来源:id=2480" style="color:rgb(106,57,6); text-decoration:none">POJ 2480 Longge's ...

  10. generate alphanumeric serial number

    generate alphanumeric serial number with the following BADI / Customer Exit: Name of Enhancement : I ...