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. [书目20140902]实战Windows Azure——微软云计算平台技术详解 --徐子岩

    目录第1章  云计算技术简介    1.1  云计算所要解决的问题    1.2  云计算平台的分类    1.3  微软云计算平台Windows Azure        1.3.1  高可用性   ...

  2. 7.JAVA-类继承、覆写、final关键字

    1.JAVA继承-extends 在java中,要想实现继承则使用extends关键字. 一般子类被称为派生类,父类称为基类(super) extends需要注意的地方: java不允许多重继承(一个 ...

  3. 学JAVA第二十二天,StringBuffer的好处

    五一的假期今天就结束了,又要回来上课了. 今天就写一下StringBuffer的好处吧. StringBuffer类的对象能够被多次的修改,并且不产生新的未使用对象. 也就是说,我们平时用String ...

  4. mysql之通过cmd连接远程数据库

    ---恢复内容开始--- 目录 前提 连接远程数据库 前提: 本地安装了mysql数据库 本地和远程网络是连通的,通过命令ping ip (即ping 192.168.0.333),可以ping通 连 ...

  5. mysql执行语句汇总

    插入select的数据 INSERT INTO `test1`( order_id, goods_id, goods_name, goods_sn, product_id, goods_number, ...

  6. C# 方法 虚方法的调用浅谈 引用kdalan的博文

    我们在面试中经常碰到有关多态的问题,之前我也一直被此类问题所困扰,闹不清到底执行哪个方法. 先给出一道简单的面试题,大家猜猜看,输出是?     public class A    {         ...

  7. vba根据部门分别汇总不同部门下的人员不同培训内容的时长总计,多条件求和

    Option Explicit Sub yy() Dim d, arr, s$, i&, m&, w$ Set d = CreateObject("Scripting.Dic ...

  8. Codeforces_B.Maximum Sum of Digits

    http://codeforces.com/contest/1060/problem/B 题意:将n拆为a和b,让a+b=n且S(a)+S(b)最大,求最大的S(a)+S(b). 思路:考虑任意一个数 ...

  9. ansible配置mysql主从复制

    配置主机1.下载安装所需安装包 [root@server1 ansible]# lsansible-2.7.8-1.el7.noarch.rpmansible-tower-setup-bundle-3 ...

  10. COPY - 在表和文件之间拷贝数据

    SYNOPSIS COPY tablename [ ( column [, ...] ) ] FROM { 'filename' | STDIN } [ [ WITH ] [ BINARY ] [ O ...