제출 #245886

#제출 시각아이디문제언어결과실행 시간메모리
245886Fasho철로 (IOI14_rail)C++14
100 / 100
200 ms764 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; } } }

컴파일 시 표준 에러 (stderr) 메시지

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:27:12: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
  for(auto &[d, i] : stations) {
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...