제출 #160692

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
1606922019-10-29 10:44:04rama_pangRail (IOI14_rail)C++14
100 / 100
207 ms98936 KiB
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
const int C_STATION = 1;
const int D_STATION = 2;
int N;
vector<int> station, type;
vector<vector<int>> G;
inline int distance(int a, int b) {
if (a == b) G[a][b] = 0;
if (G[a][b] == -1) G[a][b] = G[b][a] = getDistance(a, b);
return G[a][b];
}
void solve(int pivot, vector<int> candidate) {
if (candidate.empty()) return;
const int SAME_TYPE = type[pivot];
const int DIFF_TYPE = (type[pivot] == C_STATION)? D_STATION : C_STATION;
const int SIGN = (SAME_TYPE == C_STATION)? +1 : -1;
vector<int> cur;
cur.push_back(candidate.front());
candidate.erase(candidate.begin());
station[cur[0]] = station[pivot] + SIGN * distance(pivot, cur[0]);
type[cur[0]] = DIFF_TYPE;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...