Submission #835124

#TimeUsernameProblemLanguageResultExecution timeMemory
835124LiudasRail (IOI14_rail)C++17
30 / 100
46 ms716 KiB
#include "rail.h" #include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> #include "rail.h" #include <set> #include <vector> #include <numeric> #include <algorithm> #include <iostream> #include <map> using namespace std; void findLocation(int N, int first, int location[], int stype[]) { int lid = 0, rid = -1; vector<int> dist(N, 0); for(int i = 0; i < N; i ++){ if(i == lid)continue; int temp = getDistance(lid, i); dist[i] = temp; } vector<int> order(N); iota(order.begin(), order.end(), 0); sort(order.begin(), order.end(), [&](int a, int b){return dist[a] < dist[b];}); int d = dist[order[1]]; rid = order[1]; lid = order[0]; stype[order[0]] = 1; stype[order[1]] = 2; location[order[0]] = first; location[order[1]] = first + d; map<int, int> who; who[location[order[0]]] = lid; who[location[order[1]]] = rid; for(int i : order){ if(stype[i])continue; int t1 = getDistance(lid, i); int t2 = getDistance(rid, i); int type = stype[who[location[lid] + (t1 - t2 + d) / 2]]; //cout << type << endl; if (type == 2){ stype[i] = 1; location[i] = location[rid] - t2; if(t2 > d){ d = t2; lid = i; } who[location[i]] = i; } else{ stype[i] = 2; location[i] = location[lid] + t1; if(t1 > d){ d = t1; rid = i; } who[location[i]] = i; } } //for(int i = 0; i < N; i ++) cout << location[i] << " "; //cout << endl; //for(int i = 0; i < N; i ++)cout << stype[i] << " "; //cout << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...