# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308667 | 2020-10-01T16:47:14 Z | kris01 | Stations (IOI20_stations) | C++14 | 870 ms | 1096 KB |
#include "stations.h" #include <bits/stdc++.h> #include <vector> int timer = 0; using namespace std; vector < vector <int> > Adj; vector <int> tin,tout,depth; void PREP(int n) { Adj.clear(); tin.clear(); tout.clear(); depth.clear(); Adj.resize(n); tin.resize(n); tout.resize(n); depth.resize(n); depth[1] = 0; timer = 1; } void DFS(int v,int p) { tin[v] = timer; timer++; for (int x : Adj[v]) { if (x == p) continue; DFS(x,v); depth[x] = depth[v] + 1; } tout[v] = timer; timer++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { vector <int> labels(n); PREP(n); for (int i = 0;i < n-1;i++) { int a = u[i]; int b = v[i]; Adj[a].push_back(b); Adj[b].push_back(a); } DFS(1,-1); for (int i = 0;i < n;i++) { if (depth[i] % 2 == 0) { labels[i] = tin[i]; } else { labels[i] = tout[i]; } } return labels; } int find_next_station(int s, int t, std::vector<int> c) { if (c.back() < s) { c.push_back(s); sort(c.begin(),c.end()); for (int i = 1;i < c.size()-1;i++) { if (c[i] <= t && c[i+1] > t) { return c[i]; } } return c[0]; } else { c.push_back(s); sort(c.begin(),c.end()); for (int i = 0;i < c.size()-1;i++) { if (c[i] >= t && c[i+1] < t) { return c[i]; } } return c.back(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 512 KB | Invalid labels (values out of range). scenario=2, k=1000, vertex=4, label=1711 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 384 KB | Invalid labels (values out of range). scenario=0, k=1000, vertex=3, label=1481 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 570 ms | 1024 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 870 ms | 640 KB | Output is correct |
2 | Incorrect | 672 ms | 640 KB | Wrong query response. |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 536 ms | 1096 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |