m很小啊……暴力就好了
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=200010;
int t,n,m,x[N],y[N],vis[N];
int main(){
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&y[i]);
for(int i=0;i<=m*2;i++) vis[i]=0;
int ANSED=0;
for(int i=1;i<=n && !ANSED;i++)
for(int j=i+1;j<=n;j++){
if(vis[abs(x[i]-x[j])+abs(y[i]-y[j])]){
ANSED=1; break;
}
vis[abs(x[i]-x[j])+abs(y[i]-y[j])]=1;
}
if(ANSED) puts("YES");
else puts("NO");
}
return 0;
}
本文介绍了一种通过暴力枚举方法来判断一组点是否存在重复距离的问题解决方案。使用C++实现,通过对每两个点之间的曼哈顿距离进行比较,确保没有相同的距离出现。适用于m值较小的情况。
302

被折叠的 条评论
为什么被折叠?



