Submission #653669

#TimeUsernameProblemLanguageResultExecution timeMemory
653669LoboRail (IOI14_rail)C++17
30 / 100
76 ms1092 KiB
#include "rail.h" #include<bits/stdc++.h> using namespace std; const int maxn = 5050; map<int,int> d[maxn]; int p[maxn], tp[maxn]; int dist(int a, int b) { if(d[a].count(b)) return d[a][b]; return d[a][b] = getDistance(a,b); } void findLocation(int N, int first, int location[], int stype[]) { int n = N; p[0] = first; tp[0] = 0; // find the closest to 0 int b = -1; for(int i = 1; i < n; i++) { if(b == -1 || dist(0,i) < dist(0,b)) b = i; } p[b] = p[0]+dist(0,b); tp[b] = 1; // find the closest to b int a = -1; for(int i = 0; i < n; i++) { if(i == b) continue; if(a == -1 || dist(b,i) < dist(b,a)) a = i; } p[a] = p[b]-dist(b,a); tp[a] = 0; // location[0] = p[0]; // stype[0] = tp[0]+1; // for(int i = 1; i < n; i++) { // location[i] = dist(0,i)+p[0]; // // cout << i << " - " << dist(0,i) << endl; // stype[i] = 2; // } location[a] = p[a]; stype[a] = tp[a]+1; location[b] = p[b]; stype[b] = tp[b]+1; for(int i = 0; i < n; i++) { if(i == a || i == b) continue; if(dist(a,i) <= dist(b,i)) { location[i] = p[a]+dist(a,i); stype[i] = 2; } else { location[i] = p[b]-dist(b,i); stype[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...