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. 【洛谷3822】[NOI2017] 整数(线段树压位)

    题目: 洛谷 3822 分析: 直接按题意模拟,完了. 将每次加 / 减拆成不超过 \(32\) 个对单独一位的加 / 减. 考虑给一个二进制位(下称「当前位」)加 \(1\) 时,如果这一位本来就是 ...

  2. 使用Apache Commons IO组件读取大文件

    Apache Commons IO读取文件代码如下: Files.readLines(new File(path), Charsets.UTF_8); FileUtils.readLines(new ...

  3. CentOS 6.5使用:[3]使用xftp传递文件

    先检查CentOS系统是否安装了FTP服务 [root@centos ~]# rpm -qa | grep vsftpd 如果有内容输出,那么恭喜你,你的系统已经安装了ftp服务   如果没有那么按照 ...

  4. 专 linux命令之set x详解

    set -x与set +x指令   用于脚本调试.set是把它下面的命令打印到屏幕 set -x 是开启 set +x是关闭 set -o是查看 (xtrace),set去追中一段代码的显示情况. 执 ...

  5. windows deintall 12c client

    1.unintall: close all oracle app C:\app\client\CICadmin\product\12.1.0\client_1\deinstall deinstall ...

  6. vue全局loading组件

    本组件作用在页面加载完成前进行loader提示,提升用户体验,只需要在app.vue中引用一次,整个项目中路由切换时就可以自动进行提示(vuex版): 1. 添加vuex值和方法: import Vu ...

  7. [转]Git分支管理策略

    如果你严肃对待编程,就必定会使用"版本管理系统"(Version Control System). 眼下最流行的"版本管理系统",非Git莫属. 相比同类软件, ...

  8. 详解java中staitc关键字

    一.static定义 static是静态修饰符意思,什么叫静态修饰符呢?大家都知道,在程序中任何变量或者代码都是在编译时由系统自动分配内存来存储的,而所谓静态就是指在编译后所分配的内存会一直存在,直到 ...

  9. greenplum4.3.8.2安装

    GREENPLUM总体结构:   数据库由Master Severs和Segment Severs通过Interconnect互联组成. Master主机负责:建立与客户端的连接和管理:SQL的解析并 ...

  10. vue2.0版本指令v-if与v-show的区别

    v-if: 判断是否加载,可以减轻服务器的压力,在需要时加载. v-show:调整css dispaly属性,可以使客户端操作更加流畅. v-if示例: <!DOCTYPE html> & ...