| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1337254 | vahagng | 철로 (IOI14_rail) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "rail.h"
#include "grader.h"
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x) cerr << #x <<" "; print(x); cerr << endl;
#else
#define dbg(x)
#endif
void print(long long t) { cerr << t; }
void print(int t) { cerr << t; }
void print(string t) { cerr << t; }
void print(char t) { cerr << t; }
void print(double t) { cerr << t; }
void print(long double t) { cerr << t; }
void print(unsigned long long t) { cerr << t; }
template <class T, class V> void print(pair <T, V> p);
template <class T> void print(vector <T> v);
template <class T> void print(set <T> v);
template <class T, class V> void print(map <T, V> v);
template <class T> void print(multiset <T> v);
template <class T, class V> void print(T v[], V n) { cerr << "["; for (int i = 0; i < n; i++) { cerr << v[i] << " "; } cerr << "]"; }
template <class T, class V> void print(pair <T, V> p) { cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}"; }
template <class T> void print(vector <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(set <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(multiset <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T, class V> void print(map <T, V> v) { cerr << "[ "; for (auto i : v) { print(i); cerr << " "; } cerr << "]"; }
bool used[101];
void findLocation(int n, int first, int location[], int stype[]) {
int k = 1;
int cur = 0;
used[0] = 1;
while (k < n) {
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) {
if (used[i]) continue;
v.push_back({ getDistance(cur, i), i });
}
sort(v.begin(), v.end());
// dbg(cur);
// dbg(v);
stype[v[0].second] = 3 - stype[cur];
if (stype[cur] == 1) {
location[v[0].second] = location[cur] + v[0].first;
}
else {
location[v[0].second] = location[cur] - v[0].first;
}
used[v[0].second] = 1;
cur = v[0].second;
k++;
}
}