#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define st first
#define nd second
#define pb push_back
const int MAXN = 1007;
vector<int> graf[MAXN];
int kt = 0;
int jakie[MAXN];
void dfs(int v, int last, int dl) {
if (dl % 2 == 0) {
jakie[v] = kt;
kt++;
}
for (auto syn: graf[v]) {
if (syn == last) continue;
dfs(syn, v, dl + 1);
}
if (dl % 2 == 1) {
jakie[v] = kt;
kt++;
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
rep(i, n) {
graf[i].clear();
jakie[i] = 0;
}
rep(i, n - 1) {
int a = u[i];
int b = v[i];
graf[a].pb(b);
graf[b].pb(a);
}
kt = 0;
dfs(0, 0, 0);
vector<int> labels;
rep(i, n) {
labels.pb(jakie[i]);
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
int sz = c.size();
if (sz == 1) {
return c[0];
}
if (s < c[0]) {
if (s > t) {
return c[sz - 1];
}
int it = 0;
while (it < sz - 1 && c[it] < t) {
it++;
}
return c[it];
}
if (t > s) {
return c[0];
}
int it = sz - 1;
while (it > 0 && c[it] > t) {
it--;
}
return c[it];
}
# | 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... |