Teacher Bo

                                                        Time
Limit: 4000/2000 MS (Java/Others)    

                                                   Memory Limit: 131072/131072 K (Java/Others)

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

这题实在找不到什么方法做了,只能暴力试试,可是居然卡在曼哈顿路径的概念上了;

我们以为是两点间的距离公示,然后用hypot( ,)WA了两遍,之后两小时一直像睡着了了一样;

早知道百度一下概念,也不会耽误这么多时间,最后两分钟改了求距离那里直接交一发A了;

#include<bits/stdc++.h>
using namespace std;
const int N=100000+10;
struct node
{
int x,y;
} a[N];
int cmp(node a,node b)
{
if(a.x!=b.x) return a.x<b.x;
return a.y<b.y;
}
int main()
{
int t,n,m;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
set<double>m;
for(int i=0; i<n; i++)
scanf("%d%d",&a[i].x,&a[i].y);
sort(a,a+n,cmp);
for(int i=1; i<n; i++)
{
if(a[i].x==a[i-1].x&&a[i].y==a[i-1].y)
{
for(int j=i+1; j<n; j++)
a[j]=a[j-1];
n--;
i--;
}
}
int f=0;
for(int i=0; i<n; i++)
{
if(f) break;
for(int j=i+1; j<n; j++)
{
double dis=abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y);//主要还是概念没搞清,其他地方全正确;
if(m.find(dis)!=m.end())
{
f=1;
break;
}
m.insert(dis);
}
}
if(f) printf("YES\n");
else printf("NO\n");
}
return 0;
}

同!志!仍!需!努!力!

2016 Multi-University Training Contest 3-1011.Teacher Bo,暴力!的更多相关文章

  1. 2016 Al-Baath University Training Camp Contest-1

    2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...

  2. hdu 5762 Teacher Bo 暴力

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

  3. 2016 Multi-University Training Contest 5 1011 Two DP

    http://acm.hdu.edu.cn/showproblem.php?pid=5791 HDU5791 Two 题意 :两个数组,多少个不连续子串相等 思路: dp[i][j] :a串i结尾,b ...

  4. 2016 Multi-University Training Contest 3 1011【鸽巢原理】

    题解: 坐标(0,m)的话,闭区间,可能一共有多少曼哈顿距离? 2m 但是给一个n,可能存在n(n+1)/2个曼哈顿距离 所以可以用抽屉原理了 当n比抽屉的数量大,直接输出yes 不用计算 那...N ...

  5. 2016 Al-Baath University Training Camp Contest-1 E

    Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...

  6. 2016 Al-Baath University Training Camp Contest-1 C

    Description Rami went back from school and he had an easy homework about bitwise operations (and,or, ...

  7. 2016 Al-Baath University Training Camp Contest-1 A

    Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...

  8. 2016 Al-Baath University Training Camp Contest-1 J

    Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...

  9. 2016 Al-Baath University Training Camp Contest-1 I

    Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...

  10. 2016 Al-Baath University Training Camp Contest-1 H

     Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...

随机推荐

  1. Miller&&Pollard HDOJ 4344 Mark the Rope

    题目传送门 题意:一个长为n(n<2^63)的管子,在管子上做标记,每隔L个长度单位做一个标记,从管子头端开始,保证最后一次标记恰好在管子的尾端.让你找出有多少个这样的L(L<n),且他们 ...

  2. 善用oss客户端工具

    有个需求:需要我到阿里oss上下载ts文件 估摸了一下100多个只占了6分之一的时间,全下下来得700多个 还不算上正在运行的 正当我手动一个一个点的时候: 100个 总算点完了 全部在桌面是摆着: ...

  3. TC609 DIV1 (500)

    Problem Statement      We have balls of K different colors. The colors are numbered 0 through K-1, a ...

  4. Hibernate配置(通过注解配置)

    本文主要讲通过注解配置来替换Hibernate的映射文件 1.多对一配置 package com.jazz7.entity; import java.util.Date; import javax.p ...

  5. sql语句添加一列标示,然后进行分页。

    ,) , sum(Score) as Score ,Student_NO,Student_Name into #a2_tab from ksy_stu_ScoreInfo GROUP BY Stude ...

  6. web 自动化测试 selenium基础到应用(目录)

    第一章   自动化测试前提及整体介绍 1-1功能测试和自动化测试的区别 1-2自动化测试流程有哪些 1-3自动化测试用例和手工用例的区别 1-4 自动化测试用例编写 1-5 selenium的优势以及 ...

  7. mysql中int(1)与int(10)的区别

    INT[(M)] [UNSIGNED] [ZEROFILL] 普通大小的整数.带符号的范围是-2147483648到2147483647.无符号的范围是0到4294967295. INT(1) 和 I ...

  8. 简述SVN服务器配置和客户端操作

    有关SVN服务器的搭建见:http://www.cnblogs.com/DwyaneTalk/p/3997688.html 搭建好环境之后,服务器端需要完成如下操作: 1.需要新建Repository ...

  9. JS获取服务器端控件ID

    很多时候我们需要在JS中对服务器端控件进行一些简单处理,但是这个时候没有必要回发到服务器,让服务器去处理,这个时候就又要用到JS了 那么怎么去获取这个服务器端控件呢?我们知道服务器最终返回到用户界面的 ...

  10. widows&l ubuntu 简单互联——基于samba

    只是简单访问对方文件,就不上SSH了 windows端访问ubuntu: 要共享的文件夹右键 → 本地网络共享:共享此目录. 会提示你安装一个协议包,即samba(但此处默认安装包不完整),安装成功后 ...