#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> deg(n);
vector<vector<int>> adj(n);
for (int i = 0; i < n - 1; i++)
deg[u[i]]++, deg[v[i]]++, adj[u[i]].push_back(v[i]), adj[v[i]].push_back(u[i]);;
vector<int> labels(n);
function<void(int,int)> init = [&](int u, int p) {
if (~p) adj[u].erase(find(adj[u].begin(), adj[u].end(), p));
for (int v: adj[u])
init(v, u);
};
init(0, -1);
function<void(int,int)> dfs;
function<void(int,int,int,int)> join = [&](int u, int l, int r, int v) {
if (l > r) return;
if (l == r)
dfs(adj[u][l], v);
else {
int m = (l+r) / 2;
join(u, l, m, v*2+1);
join(u, m+1, r, v*2+2);
}
};
dfs = [&](int u, int l) {
labels[u] = l;
join(u, 0, adj[u].size()-1, l);
};
dfs(0, 0);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
set<int> tmp; for (int x: c) tmp.insert(x+1);
int y = t+1;
if (tmp.count(y)) return y-1;
while (y > 0) {
y /= 2;
if (tmp.count(y))
return y-1;
}
return *min_element(c.begin(), c.end());
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
512 KB |
Invalid labels (duplicates values). scenario=0, label=2 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Invalid labels (duplicates values). scenario=0, label=497 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
504 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
512 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |