Submission #599951

#TimeUsernameProblemLanguageResultExecution timeMemory
599951LucppRail (IOI14_rail)C++17
30 / 100
78 ms708 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; void findLocation(int n, int first, int location[], int stype[]){ stype[0] = 1; location[0] = first; vector<pair<int, int>> dist0; for(int i = 1; i < n; i++){ int d = getDistance(0, i); dist0.emplace_back(d, i); } sort(dist0.begin(), dist0.end()); stype[dist0[0].second] = 2; location[dist0[0].second] = first+dist0[0].first; map<int, int> C, D; C.emplace(first, 0); D.emplace(location[dist0[0].second], dist0[0].second); for(int i = 1; i < n-1; i++){ auto [d0, ind] = dist0[i]; int dc = getDistance(C.begin()->second, ind); int dd = getDistance(D.rbegin()->second, ind); int rd = D.rbegin()->first; int rc = C.rbegin()->first; int ld = D.begin()->first; int lc = C.begin()->first; if(first+d0 == rd+dd-2*(rd-rc)){ stype[ind] = 2; location[ind] = first+d0; D.emplace(first+d0, ind); } else if(rd-dd > first){ stype[ind] = 1; location[ind] = rd-dd; C.emplace(rd-dd, ind); } else{ d0 = first-(rd-dd); if(first-d0 == lc-dc+2*(ld-lc)){ stype[ind] = 1; location[ind] = first-d0; C.emplace(first-d0, ind); } else{ stype[ind] = 2; location[ind] = lc+dc; D.emplace(lc+dc, ind); } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...