Submission #132456

#TimeUsernameProblemLanguageResultExecution timeMemory
132456SortingRail (IOI14_rail)C++14
30 / 100
84 ms504 KiB
#include <bits/stdc++.h> #include "rail.h" using namespace std; const int inf = 1e9; const int N = 5007; int getDistance(int i, int j); int d[N][N]; void findLocation(int n, int first, int location[], int stype[]){ location[0] = first; stype[0] = 1; int mn = inf, x = 0; for(int i = 1; i < n; i++){ d[0][i] = getDistance(0, i); mn = min(mn, d[0][i]); if(mn == d[0][i]){ x = i; } } for(int i = 1; i < n; i++){ if(i == x){ stype[i] = 2; location[i] = first + mn; continue; } if(getDistance(i, x) == d[0][i] - mn){ stype[i] = 1; location[i] = first - (d[0][i] - 2 * mn); } else{ stype[i] = 2; location[i] = first + d[0][i]; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...