首先,我们知道博弈的策略其实是把必输的策略留给对手。体现在这题中,就是当对手选中的边抵达最大边的一端时,然后我们选择最大边,则我们胜利。
那么我们就要想办法把最大边的一端留给对手,以此类推的,我们倒着标记最大边的两端。然后逐个标记,两端没有被标记的次大边,次次大边等。当我们的第一个点被标记时,我们就获得了游戏胜利。
理由就是,从第一点出发,我们只要沿着最大边选,我们一定有得选,而对手只能选没同时标记两端的边(如果标记过,那么我们也不可能能选到)。那么到最后,对手一定会选到最大边的一端,而我们则会选到最大边。
说实话最近打多校挺憋屈的,不会的很多,菜的抠脚,想喷队友,其实自己也是菜狗。 唉,道阻且长,你我共勉。
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
const int maxn = 2e3 + 5;
struct node{
int x, y;
LL d;
bool operator < (const node&a) const{
return d > a.d;
}
}dis[maxn*maxn];
LL x[maxn], y[maxn];
bool vis[maxn];
int main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int T, n;
cin >> T;
while(T--){
cin >> n;
memset(vis, 0, sizeof(vis));
int tol = 0;
for(int i = 1; i <= n; i++)
cin >> x[i] >> y[i];
for(int i = 1; i <= n; i++)
for(int j = i + 1; j <= n;j++)
dis[tol++] = node{i, j, (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])};
sort(dis, dis + tol);
for(int i = 0; i < tol; i++){
if(!vis[dis[i].x] && !vis[dis[i].y])
vis[dis[i].x] = vis[dis[i].y] = true;
}
if(vis[1]) cout << "YES" << endl;
else cout << "NO" << endl;
}
}