제출 #548269

#제출 시각아이디문제언어결과실행 시간메모리
548269sidon철로 (IOI14_rail)C++17
30 / 100
76 ms772 KiB
#include <bits/stdc++.h> using namespace std; #include "rail.h" void findLocation(int N, int o, int* x, int* t) { int d[N] {}, byD[N - 1]; map<int, int> g; t[0] = g[x[0] = o] = 1; for(int v = 1; v < N; ++v) { d[v] = getDistance(0, v); byD[v-1] = v; } sort(byD, byD + N - 1, [&](const int &i, const int &j) { return d[i] < d[j]; }); int c = byD[0], rD = c, lD = c, rC {}, lC {}; t[c] = g[x[c] = o + d[c]] = 2; for(const int &v : byD) if(v != c) { int z = getDistance(c, v); if(z > d[v]) { int y = getDistance(rD, v); int xU = (x[rD] + (o + d[v]) - y) / 2; if((!(((x[rD] + (o + d[v]) - y)) & 1) && g[xU] == 2)) x[v] = x[rD] - y , t[v] = 1; else x[rD = v] = o + d[v], t[v] = 2; } else { int y = getDistance(lC, v); if(!lC) x[lC = v] = x[c] - z, t[v] = 1; else { int xU = (y + x[lC] + (x[c] - z)) / 2; if(!(((y + x[lC] + (x[c] - z))) & 1) && g[xU] == 1) x[v] = x[lC] + y, t[v] = 2; else x[lC = v] = x[c] - z, t[v] = 1; } } if(t[v] == 1 && x[v] > x[rC]) rC = v; if(t[v] == 2 && x[v] < x[lD]) lD = v; g[x[v]] = t[v]; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...