【链接】
hdu5762
【题目大意】
应该很好读懂吧
【解题报告】
由题目意思可知只要判断两个点之间的曼哈顿距离是否在之前出现过即可,因为坐标范围只有 105 ,所以最大的曼哈顿距离只有 2∗105 ,所以直接暴枚就可以了,复杂度 O(T∗2∗105) 。
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=200005;
int T,n,m;
bool vis[maxn];
struct Point
{
int x,y;
}a[maxn];
inline int Read()
{
int res=0;
char ch=getchar();
while (ch<'0'||ch>'9') ch=getchar();
while (ch>='0'&&ch<='9') res=res*10+ch-48,ch=getchar();
return res;
}
int Abs(int x) {if (x<0) return (-x); return x;}
void Work()
{
n=Read(); m=Read(); bool pd=0;
for (int i=1; i<=n; i++) a[i]=(Point){Read(),Read()};
memset(vis,0,sizeof(vis));
for (int i=1; i<n; i++)
{
for (int j=i+1; j<=n; j++)
{
int k=Abs(a[i].x-a[j].x)+Abs(a[i].y-a[j].y);
if (vis[k]) {pd=1; break;} else vis[k]=1;
}
if (pd) break;
}
if (pd) printf("YES"); else printf("NO"); putchar(10);
}
int main()
{
freopen("5762.in","r",stdin);
freopen("5762.out","w",stdout);
T=Read();
while (T--) Work();
return 0;
}