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 "stations.h"
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<bool> vb;
typedef long long ll;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<vi> vvi;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vvi adj(n);
forR(i, n-1) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
vi to(n);
forR(i, n-1) {
if(adj[i].size() == 1) {
int pre=-1, cur=i, ci = 0;
do {
int nex = adj[cur][0] == pre ? adj[cur][1] : adj[cur][0];
to[cur] = ci++;
pre = cur;
cur = nex;
} while(adj[cur].size() != 1);
to[cur] = ci++;
}
}
return to;
}
int find_next_station(int s, int t, std::vector<int> c) {
cerr << s << ' ' << t << '\n';
if(t > s) return c[0] > s ? c[0] : c[1];
return c[0] < s ? c[0] : c[1];
}
# | 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... |