#include <bits/stdc++.h>
using namespace std;
vector<int> st, en, d;
vector<vector<int>> adj;
int t;
void dfs(int curr, int par) {
st[curr] = t++;
for(int next : adj[curr]) {
if(next == par) continue;
d[next] = d[curr] + 1;
dfs(next, curr);
}
en[curr] = t++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
adj.clear(), st.clear(), en.clear(), d.clear();
adj.resize(n);
st.resize(n);
en.resize(n);
d.resize(n);
for(int i = 0; i < n - 1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
vector<int> ans(n);
t = 0;
dfs(0, -1);
for(int i = 0; i < n; i++) {
if(d[i] % 2 == 0) ans[i] = st[i] / 2;
else ans[i] = en[i] / 2;
}
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
if(c[0] < s) {
for(int i = (int) c.size() - 1; i >= 1; i--) {
if(t >= c[i] && t <= s) return c[i];
}
}
else {
for(int i = 0; i < (int) c.size() - 1; i++) {
if(t <= c[i] && t >= s) return c[i];
}
}
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
561 ms |
648 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
531 ms |
616 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
596 ms |
616 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1020 ms |
400 KB |
Output is correct |
2 |
Incorrect |
828 ms |
488 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
588 ms |
656 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |