Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
28582 LYLAKIOI 【BJ】T1 C++ 运行超时 52 1000 MS 360 KB 1538 2024-04-26 17:53:36

Tests(63/65):


#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 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; ll a[maxn],b[maxn]; int P[maxn]; 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 SA(){ up(i,1,n)P[i]=i;random_shuffle(P+1,P+n+1); int now=g(); if(!now){ up(i,1,n)printf("%d%c",P[i],(i<n?' ':'\n')); exit(0); } double T=1000; while(T>1e-4){ int x=rand()%n+1,y=rand()%n+1; swap(P[x],P[y]); int qwq=g(); if(qwq<now)now=qwq; //else if(exp(-(qwq-now)/T)>rand())now=qwq; else swap(P[x],P[y]); if(!now){ up(i,1,n)printf("%d%c",P[i],(i<n?' ':'\n')); exit(0); } T*=0.9997; } } void slv(){ n=read();up(i,1,n)a[i]=read(),b[i]=read(); while(1)SA(); }int main(){ // freopen("assign.in","r",stdin); // freopen("assign.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }


测评信息: