Submission #773971

#TimeUsernameProblemLanguageResultExecution timeMemory
773971boris_mihovRail (IOI14_rail)C++17
30 / 100
45 ms524 KiB
#include "rail.h" #include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> typedef long long llong; const int MAXN = 100000 + 10; const int INF = 1e9; int n; int distA[MAXN]; int distB[MAXN]; int myDist(int u, int v) { return getDistance(u - 1, v - 1); } void findLocation(int N, int first, int location[], int stype[]) { n = N; for (int i = 2 ; i <= n ; ++i) { distA[i] = myDist(1, i); } location[0] = first; stype[0] = 1; int minIdx = 2; for (int i = 3 ; i <= n ; ++i) { assert(distA[i] != distA[minIdx]); if (distA[i] < distA[minIdx]) { minIdx = i; } } location[minIdx - 1] = first + distA[minIdx]; stype[minIdx - 1] = 2; for (int i = 2 ; i <= n ; ++i) { if (i == minIdx) { continue; } distB[i] = myDist(minIdx, i); } for (int i = 2 ; i <= n ; ++i) { if (i == minIdx) { continue; } if (distA[i] == distB[i] + location[minIdx - 1] - location[0]) { stype[i - 1] = 1; location[i - 1] = location[minIdx - 1] - distB[i]; } if (distB[i] == distA[i] + location[minIdx - 1] - location[0]) { stype[i - 1] = 2; location[i - 1] = distA[i] + 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...