#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> tree;
vector<int> labels, tin, sub;
int n, t;
void dfs(int node, int par) {
tin[node] = t++;
sub[node] = 1;
for (auto next: tree[node]) {
if (next == par) continue;
dfs(next, node);
sub[node] += sub[next];
}
}
vector<int> label(int N, int k, vector<int> u, vector<int> v) {
n = N;
labels.assign(n, -1);
for (int i = 0; i < n; i++) labels[i] = i;
return labels;
/*
tree.clear();
tree.resize(n);
labels.clear();
labels.assign(n, -1);
t = 0;
tin.assign(n, 0);
sub.assign(n, 0);
for (int i = 0; i < n-1; i++) {
tree[u[i]].push_back(v[i]);
tree[v[i]].push_back(u[i]);
}
dfs(0, 0);
for (int i = 0; i < n; i++) {
int ord = tin[i];
int tot = sub[i];
int val = 0;
for (int i = 0; i < 10; i++) {
if ((ord >> i) & 1) val |= (1 << i);
}
for (int i = 10; i < 20; i++) {
int j = i - 10;
if ((tot >> j) & 1) val |= (1 << i);
}
labels[i] = val;
}
return labels;*/
}
bool search(int node, int t) {
if (node > 1000) return false;
if (node == t) return true;
return search(node*2+1, t) || search(node*2+2, t);
}
int find_next_station(int s, int t, vector<int> c) {
int ch = c.size();
sort(c.begin(), c.end());
if (c.size() == 1) return c[0];
if (search(2*s+1, t)) {
if (c.size() == 2) return c[0];
else return c[1];
}
if (search(2*s+2, t)) {
if (c.size() == 2) return c[1];
else return c[2];
}
return c[0];
/*
int par = -1;
int need = 0;
for (int i = 0; i < 10; i++) {
if ((t >> i) & 1) {
need |= (1 << i);
}
}
int ordCurr = 0;
for (int i = 0; i < 10; i++) {
if ((s >> i) & 1) {
ordCurr |= (1 << i);
}
}
for (auto next: c) {
int ord = 0, sub = 0;
for (int i = 0; i < 10; i++) {
if ((next >> i) & 1) {
ord |= (1 << i);
}
}
for (int i = 10; i < 20; i++) {
if ((next >> i) & 1) {
sub |= (1 << (i - 10));
}
}
if (ord < ordCurr) {
par = next;
continue;
}
int l = ord;
int r = ord + sub - 1;
if (need >= l && need <= r) return next;
}
return par;*/
}
# | 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... |