提交时间:2024-04-27 10:18:32
运行 ID: 28594
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define m_p make_pair #define p1 first #define p2 second #define p_b push_back using namespace std; typedef long long ll; const int maxn=23333; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } int n; bool used[maxn]; ll a[maxn],b[maxn]; int P[maxn]; int st1[maxn],st2[maxn],tp1,tp2; ll f(int i,int j,int k){ return a[i]*b[j]+a[j]*b[k]+a[k]*b[i]; } bool chk(int i,int j,int k){ return f(i,j,k)>=f(k,j,i); } int g(){ int res=0; up(i,1,n-2)if(!chk(P[i],P[i+1],P[i+2]))res++; return res; } void dfs(int x){ if(x>n){ up(i,1,n)printf("%d%c",P[i],(i<n?' ':'\n')); exit(0); } up(i,1,n)if(!used[i]){ if(x<=2||chk(P[x-2],P[x-1],i)){ P[x]=i; used[i]=1;dfs(x+1); used[i]=0; } } } void slv(){ n=read();up(i,1,n)a[i]=read(),b[i]=read(); dfs(1); }int main(){srand(time(0)); // freopen("assign.in","r",stdin); // freopen("assign.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }