Submission #295036

#TimeUsernameProblemLanguageResultExecution timeMemory
295036alexandra_udristoiuRail (IOI14_rail)C++14
30 / 100
151 ms632 KiB
#include "rail.h" #include<algorithm> using namespace std; void findLocation(int n, int frst, int loc[], int type[]){ int i, st, dr, dist1, dist2, x, j, minim, p; pair<int, int> v[5005]; loc[0] = frst; type[0] = 1; for(i = 1; i < n; i++){ v[i].second = i; v[i].first = getDistance(0, i); } sort(v + 1, v + n); st = 0; dr = v[1].second; loc[dr] = v[1].first + loc[0]; type[dr] = 2; for(i = 2; i < n; i++){ x = v[i].second; dist1 = getDistance(st, x); dist2 = getDistance(dr, x); p = loc[st] + dist1; minim = 10000000; for(j = 0; j < n; j++){ if(type[j] == 1){ if(loc[j] < p && loc[j] < loc[dr]){ minim = min(minim, p - loc[j] + loc[dr] - loc[j]); } } } if(dist2 == minim){ type[x] = 2; loc[x] = p; if(loc[x] > loc[dr]){ dr = x; } } else{ type[x] = 1; loc[x] = loc[dr] - dist2; if(loc[x] < loc[st]){ st = x; } } } int abc = 0; }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:47:9: warning: unused variable 'abc' [-Wunused-variable]
   47 |     int abc = 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...