#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=2e3+5;
long long map1[N][N];
struct node
{
ll x;
ll y;
}a[N];
struct edge
{
ll a;
ll b;
ll dis;
}e[N*N];
int vis[N];
bool cmp(edge a,edge b)
{
return a.dis>b.dis;
}
int main()
{
int T;
cin>>T;
while(T--)
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].x>>a[i].y;
}
int cnt = 0;
for(ll i=1;i<=n;i++)
{
for(ll j=i+1;j<=n;j++)
{
cnt++;
e[cnt].dis = (a[i].x -a[j].x)*(a[i].x -a[j].x) +(a[i].y -a[j].y)*(a[i].y -a[j].y);
e[cnt].a = i;
e[cnt].b = j;
//printf("nmd%d %d\n",i,j);
}
}
sort(e+1,e+cnt+1,cmp);
memset(vis,0,sizeof vis);
int pos = 1;
int pre = 0 ;
while(pos<=cnt)
{
pre=pos;
while(pos<=cnt && e[pos].dis==e[pre].dis) pos++;
for (int i=pre;i<pos;i++)
if (! vis[e[i].b] && ! vis[e[i].a])
{
//printf(" %lld %lld\n",e[i].a,e[i].b);
vis[e[i].a]=1,vis[e[i].b]=1;
}
}
if(vis[1])
printf("YES\n");
else
printf("NO\n");
}
}
2020杭电多校第七场 1007GAME
最新推荐文章于 2020-08-17 15:32:58 发布