Submission #7724

#TimeUsernameProblemLanguageResultExecution timeMemory
7724dohyun0324Rail (IOI14_rail)C++98
30 / 100
99 ms832 KiB
#include "rail.h" int w,arr1[5010],arr2[5010]; struct data { int num,dis; bool operator<(const data&r)const { return dis<r.dis; } }left[5010]; struct data2 { int num,dis; bool operator<(const data2&r)const { return dis<r.dis; } }right[5010]; void findLocation(int N, int first, int location[], int stype[]) { int i,k,dis=2147483647,p,s; for(i=1;i<=N-1;i++) { k=getDistance(0,i); arr1[i]=k; if(dis>k) dis=k, p=i; } stype[0]=1, location[0]=first; stype[p]=2, location[p]=dis+location[0]; for(i=1;i<=N-1;i++) { if(i==p) continue; arr2[i]=getDistance(p,i); } for(i=1;i<=N-1;i++) { if(i==p) continue; if(arr1[i]-arr2[i]==dis) { w++; left[w].dis=arr2[i]-dis; left[w].num=i; } } if(w>0){stype[left[1].num]=1; location[left[1].num]=first-left[1].dis;} s=1; for(i=2;i<=w;i++) { k=getDistance(left[i].num,left[s].num); if(k==left[i].dis-left[s].dis) { stype[left[i].num]=2; location[left[i].num]=location[left[s].num]+k; } else { stype[left[i].num]=1; location[left[i].num]=first-left[i].dis; s=i; } } w=0; for(i=1;i<=N-1;i++) { if(i==p) continue; if(arr2[i]-arr1[i]==dis) { w++; right[w].dis=arr1[i]-dis; right[w].num=i; } } if(w>0){stype[right[1].num]=2; location[right[1].num]=first+dis+right[1].dis;} s=1; for(i=2;i<=w;i++) { k=getDistance(right[i].num,right[s].num); if(k==right[i].dis-right[s].dis) { stype[right[i].num]=1; location[right[i].num]=location[right[s].num]-k; } else { stype[right[i].num]=2; location[right[i].num]=first+dis+right[i].dis; s=i; } } }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:29:12: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
     stype[p]=2, location[p]=dis+location[0];
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...