Submission #14726

#TimeUsernameProblemLanguageResultExecution timeMemory
14726gs13068Rail (IOI14_rail)C++98
0 / 100
119 ms544 KiB
#include "rail.h" #include <algorithm> std::pair<int,int> a[5555]; void findLocation(int n,int fir,int loc[],int stp[]) { int lf,rf; 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); lf=rf=0; 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)lf=1; if(j<i) { loc[a[i].second]=loc[l]+ld; stp[a[i].second]=2; if(loc[a[i].second]>loc[r])r=a[i].second; } else { loc[a[i].second]=loc[r]-rd; stp[a[i].second]=1; if(loc[a[i].second]<loc[l])l=a[i].second; } } }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:8:6: warning: variable 'lf' set but not used [-Wunused-but-set-variable]
  int lf,rf;
      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...