| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 683739 | sharaelong | 기지국 (IOI20_stations) | C++17 | 912 ms | 768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int MAX_N = 1000;
vector<int> adj[MAX_N];
int depth[MAX_N];
int tour[MAX_N];
int tour_cnt = 0;
void dfs(int here, int parent = -1) {
if (~depth[here] & 1) tour[here] = tour_cnt;
for (int there: adj[here]) {
if (there != parent) {
depth[there] = depth[here] + 1;
if (~depth[here] & 1) tour_cnt++;
dfs(there, here);
}
}
if (depth[here] & 1) {
tour[here] = tour_cnt;
} else {
tour_cnt++;
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for (int i=0; i<n; ++i) adj[i].clear();
tour_cnt = 0;
memset(depth, 0, sizeof depth);
for (int i=0; i<n-1; ++i) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0);
assert(tour_cnt == n);
vector<int> labels(n);
for (int i=0; i<n; i++) labels[i] = tour[i];
// cout << endl;
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if (c.size() == 1) return c[0];
// s is start
if (s < c[0]) {
if (s < t && t <= c[c.size()-2]) {
for (int i=0; i+1<c.size(); ++i) {
if (t <= c[i]) return c[i];
}
} else {
return c.back();
}
} else {
if (s > t && t >= c[1]) {
for (int i=1; i+1<c.size(); ++i) {
if (c[i] <= t && t < c[i+1]) return c[i];
}
return c.back();
} else {
return c[0];
}
}
assert(false);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
