Submission #14725

#TimeUsernameProblemLanguageResultExecution timeMemory
14725gs13068Rail (IOI14_rail)C++98
30 / 100
169 ms876 KiB
#include "rail.h" #include <algorithm> int getDistance(int,int); std::pair<int,int> a[5555]; void findLocation(int n,int fir,int loc[],int stp[]) { int i,j,l,r,ld,rd; loc[0]=fir; stp[0]=1; if(n==1)return; a[0].first=0; a[0].second=0; for(i=1;i<n;i++) { a[i].first=getDistance(0,i); a[i].second=i; } std::sort(a+1,a+n); loc[a[1].second]=loc[0]+a[1].first; stp[a[1].second]=2; l=0;r=a[1].second; for(i=2;i<n;i++) { ld=getDistance(l,a[i].second); rd=getDistance(r,a[i].second); for(j=0;j<i;j++)if(stp[a[j].second]==1&&loc[a[j].second]<loc[l]+ld&&loc[r]-loc[a[j].second]+loc[l]+ld-loc[a[j].second]==rd)break; if(j<i) { loc[a[i].second]=loc[l]+ld; stp[a[i].second]=2; } else { loc[a[i].second]=loc[r]-rd; stp[a[i].second]=1; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...