# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
432391 | 2021-06-18T09:06:06 Z | idk321 | 기지국 (IOI20_stations) | C++17 | 912 ms | 680 KB |
#include "stations.h" #include <vector> using namespace std; #include <bits/stdc++.h> const int M = 1000000000; const int N = 1000; int in[N]; int out[N]; vector<int> adj[N]; vector<int> labels; int n, k; int timer; int type[N]; void dfs2(int node, int par) { if (par == -1) { type[node] = 0; } else { type[node] = !type[par]; } in[node] = timer; timer++; for (int next : adj[node]) { if (next == par) continue; dfs2(next, node); } out[node] = timer; timer++; } const int add = 2000; std::vector<int> label(int n1, int k1, std::vector<int> u, std::vector<int> v) { n = n1; k = k1; labels.assign(n, 0); for (int i = 0; i < n; i++) adj[i].clear(); for (int i = 0; i < u.size(); i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } timer = 0; dfs2(0, -1); for (int i = 0; i < n; i++) { if (type[i] == 0) labels[i] = in[i] + add; else labels[i] = out[i]; } vector<int> numbers; for (int i : labels) numbers.push_back(i); sort(numbers.begin(), numbers.end()); map<int, int> turnTo; int cur = 0; for (int i : numbers) { turnTo[i] = cur; cur++; } for (int i = 0; i < labels.size(); i++) { labels[i] = turnTo[labels[i]]; } return labels; } int find_next_station(int s, int t, std::vector<int> c) { if (t >= add) t -= add; if (s >= add) { s -= add; int par = -1; if (s != 0) { for (int next : c) { if (par < next) { par = next; } } } if (t < s) return par; int take = M; for (int next : c) { if (next == par) continue; if (next < take && next >= t) { take = next; } } if (take == M) return par; return take; } else { int par = M; for (int& next : c) { next -= add; if (next < par) par = next; } if (t > s) return par + add; vector<int> children; for (int next : c) { if (next == par) continue; children.push_back(next); } if (t <= par) return par + add; int take = -1; for (int i = 0; i < children.size(); i++) { if (children[i] > t) break; take = i; } if (take == -1) return par + add; return children[take] + add; } return c[0]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 530 ms | 664 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 449 ms | 512 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 532 ms | 680 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 912 ms | 520 KB | Output is correct |
2 | Incorrect | 673 ms | 528 KB | Wrong query response. |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 531 ms | 656 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |