This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <stations.h>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1005;
int t;
vector<int> adj[NMAX];
void dfs(int x, int p, int f, vector<int>& labels){
if(!f) labels[x] = t++;
for(int&nx : adj[x])
if(nx != p) dfs(nx, x, f ^ 1, labels);
if(f) labels[x] = t++;
return;
}
vector<int>label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
for(int i = 0; i < n - 1; i++){
adj[u[i]].emplace_back(v[i]);
adj[v[i]].emplace_back(u[i]);
}
t = 0;
dfs(0, -1, 0, labels);
for(int i = 0; i < n; i++) adj[i].clear();
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
int sz = c.size();
if(s < c[0]){
for(int i = 0; i < sz; i++){
int l = !i ? s : c[i - 1] + 1, r = c[i];
if(t >= l && t <= r) return c[i];
}
return c.back();
}
else{
for(int i = 1; i < sz; i++){
int l = c[i], r = (i == sz - 1 ? s - 1: c[i + 1] - 1);
if(t >= l && t <= r) return c[i];
}
return c[0];
}
}
# | 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... |