제출 #796917

#제출 시각아이디문제언어결과실행 시간메모리
796917yikis44762철로 (IOI14_rail)C++17
100 / 100
133 ms640 KiB
#include<bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) #define FOR(i, a, b) for(int i = a; i <= b; i++) #include "rail.h" void findLocation(int N, int first, int location[], int stype[]) { auto fix = [&](int i, int pos, int type) { location[i] = pos; stype[i] = type; }; REP(i, N) fix(i, -1, -1); fix(0, first, 1); vector<pair<int, int>> stations; FOR(i, 1, N - 1) stations.emplace_back(getDistance(0, i), i); sort(stations.begin(), stations.end()); int L = 0, R = stations[0].second; fix(R, first + stations[0].first, 2); stations.erase(stations.begin()); for(auto &[d, i] : stations) { int a = getDistance(L, i); int b = getDistance(R, i); { // [)] bool ok = false; int pos = location[L] + a; REP(j, N) { if(stype[j] == 1) { if(location[R] + pos - 2 * location[j] == b) ok = true; } } if(ok) { fix(i, pos, 2); if(location[R] < pos) R = i; continue; } } { // ( int pos = location[R] - b; bool ok = false; REP(j, N) { if(stype[j] == 2) { if(location[j] * 2 - pos - location[0] == d) ok = true; } } if(ok) { fix(i, pos, 1); if(pos < location[L]) L = i; continue; } } { // []) int pos = location[L] + a; fix(i, pos, 2); R = 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...