比赛 20250520模拟测试 评测结果 AAAWAAWAAWAWAWWWAAAA
题目名称 圣诞树 最终得分 65
用户昵称 zjzhe 运行时间 0.177 s
代码语言 C++ 内存使用 3.79 MiB
提交时间 2025-05-20 16:03:02
显示代码纯文本
#include <algorithm>
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int N=1e5+5;
int n;
struct Point{
    long double x,y;
}v[N];
long double dis2(Point a,Point b){
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
#undef int  
int main(){
#define int long long  
	freopen("tree.in","r",stdin);
	freopen("tree.out","w",stdout);
	cin>>n;
    for(int i=1;i<=n;i++)cin>>v[i].x>>v[i].y;
    int k=max_element(v+1,v+1+n,[](Point itl,Point itr){return itl.y<itr.y;})-v;
    bitset<N>vs;vs[k]=1;
    for(int p=k;p;){
        cout<<p<<' ';
        int tp=0;
        for(int i=1;i<=n;i++){
            if(vs[i])continue;
            if(!tp||dis2(v[i],v[p])<dis2(v[tp],v[p]))tp=i;
        }
        if(tp)p=tp,vs[tp]=1;
        else p=0;
    }

	return 0;
}