제출 #49528

#제출 시각아이디문제언어결과실행 시간메모리
49528Namnamseo철로 (IOI14_rail)C++17
8 / 100
91 ms708 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; using pp=pair<int,int>; #define x first #define y second pp kyori[5010]; void findLocation(int n, int first, int location[], int stype[]) { for(int i=1; i<n; ++i) kyori[i-1]={getDistance(0, i), i}; sort(kyori, kyori+n-1); int L = 0, Lp = first, R = kyori[0].y, Rp = Lp + kyori[0].x; location[L] = Lp; location[R] = Rp; stype[L] = 1; stype[R] = 2; for(int i=1; i<n-1; ++i){ int j = kyori[i].y; int dl = getDistance(L, j), dr = getDistance(R, j); int jp; if(dl + (Rp-Lp) == dr){ jp = Lp + dl; stype[j] = 2; if(jp > Rp){ R = j; Rp = jp; } } else { jp = Rp - dr; stype[j] = 1; if(jp < Lp){ L = j; Lp = jp; } } location[j] = jp; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...