Submission #38845

#TimeUsernameProblemLanguageResultExecution timeMemory
3884514kgRail (IOI14_rail)C++11
30 / 100
94 ms696 KiB
#include "rail.h" #define N 5000 #define INF 999999999 int n; int zd[N], zero; int rd[N], rw, r_num; int left_num, left; int right_num, right; void findLocation(int _n, int _zero, int out1[], int out2[]) { int temp = INF; n = _n, zero = _zero; for (int i = 1; i < n; i++) { zd[i] = getDistance(0, i); if (temp > zd[i]) { temp = zd[i], r_num = i; rw = zero + temp; } } for (int i = 1; i < n; i++) if (i != r_num) rd[i] = getDistance(r_num, i); out1[0] = zero, out2[0] = 1; out1[r_num] = rw, out2[r_num] = 2; left_num = 0, left = zero; right_num = r_num, right = rw; for (int i = 1; i <= n; i++) if (i != r_num) { if (zd[i] + rw - zero == rd[i]) out1[i] = zero + zd[i], out2[i] = 2; else if (rd[i] + rw - zero == zd[i]) out1[i] = rw - rd[i], out2[i] = 1; if (out1[i] && left > out1[i]) left = out1[i], left_num = i; if (out1[i] && right < out1[i]) right = out1[i], right_num = i; } for (int i = 1; i <= n; i++) if (!out2[i]) { temp = getDistance(left_num, i); if (left + temp < right) out1[i] = left + temp, out2[i] = 2; else out1[i] = right * 2 - left - temp, out2[i] = 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...