2016 Multi-University Training Contest 3-1011.Teacher Bo,暴力!
Teacher Bo
Time
Limit: 4000/2000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
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".
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).
each line is "YES" or "NO".
2
3 10
1 1
2 2
3 3
4 10
8 8
2 3
3 3
4 4
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,暴力!的更多相关文章
- 2016 Al-Baath University Training Camp Contest-1
2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...
- hdu 5762 Teacher Bo 暴力
Teacher Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...
- 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 ...
- 2016 Multi-University Training Contest 3 1011【鸽巢原理】
题解: 坐标(0,m)的话,闭区间,可能一共有多少曼哈顿距离? 2m 但是给一个n,可能存在n(n+1)/2个曼哈顿距离 所以可以用抽屉原理了 当n比抽屉的数量大,直接输出yes 不用计算 那...N ...
- 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 ...
- 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, ...
- 2016 Al-Baath University Training Camp Contest-1 A
Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- C++默认函数与函数重载
一.默认参数 在C++中,可以为参数指定默认值.在函数调用时没有指定与形参相对应的实参时, 就自动使用默认参数. 默认参数的语法与使用:(1)在函数声明或定义时,直接对参数赋值.这就是默认参数: (2 ...
- 使用Maven将dubbox安装进资源仓库
dubbox网址:https://github.com/dangdangdotcom/dubbox dobbox版本:https://github.com/dangdangdotcom/dubbox/ ...
- Oracle查询使用空间比较大的前15个表
-- 查询使用空间比较大的前15个表 select a.* from( ,2) all_size from dba_segments where SEGMENT_TYPE='TABLE' order ...
- APP多渠道打包
多渠道打包的概念: 打包是指使用证书文件对app签名生成一个apk文件. 多渠道打包指的就是我们的app在开发完成之后需要投放到不同的市场,比如说Google市场.百度市场等,为了统计应用在各个市场的 ...
- Palindromic Subsets 数学 + 线段树
https://www.hackerrank.com/contests/101hack44/challenges/palindromic-subsets 如果有3个a.2个b.1个c. 每个a看成不同 ...
- 基于Windows7下snort+apache+php 7 + acid(或者base) + adodb + jpgraph的入侵检测系统的搭建(图文详解)(博主推荐)
为什么,要写这篇论文? 是因为,目前科研的我,正值研三,致力于网络安全.大数据.机器学习.人工智能.区域链研究领域! 论文方向的需要,同时不局限于真实物理环境机器实验室的攻防环境.也不局限于真实物理机 ...
- 点击后打开QQ临时会话
1.QQ官方提供的代码.如果没有加好友需要加好友才能聊天,也可以到这里http://shang.qq.com/v3/index.html 开通一个服务,同样可以实现临时会话. <a href=& ...
- 枚举Enum通过int值或文本转为对应的枚举类型
1.数值转枚举 如果枚举类型继承了数值类型,可以直接强制转换 public enum SourceType : byte { YC = , TS = , QK = , ZQ = } //转换方式 ; ...
- AJPFX编写cmd界面下一键编译、执行java代码的bat脚本
此脚本适合刚接触java的同学,在cmd界面下用jc取代 复杂的 javac *.java + java main使用说明:把脚本内容复制到txt文本中,修改后缀名为.bat,运行一次即可完成配置, ...
- iOS---UICollectionView详解和常用API翻译
UICollectionView 1.必须要设置布局参数 2.注册cell 用法类似于UITableView 类.自动实现重用,必须注册初始化. 使用UICollectionView必须实现UICol ...