This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 1000
#define pii pair<int, int>
#define ff first
#define ss second
#include "stations.h"
const int mul = 501;
vector<int> adj[maxn];
int in[maxn], out[maxn], siz[maxn];
int tin, tout;
void getsiz(int n, int par) {
siz[n] = 1;
for (int v:adj[n]) {
if (v != par) {
getsiz(v, n);
siz[n] += siz[v];
}
}
}
int getcentroid(int n, int par, int tot) {
for (int v:adj[n]) {
if (v != par && siz[v] * 2 > tot) {
return getcentroid(v, n, tot);
}
}
return n;
}
void dfs(int n, int par) {
in[n] = tin++;
siz[n] = 1;
for (int v:adj[n]) {
if (v != par) {
dfs(v, n);
siz[n] += siz[v];
}
}
out[n] = tout++;
}
std::vector<int> label(int n, int LIM, std::vector<int> U, std::vector<int> V) {
vector<int> ret(n);
for (int i = 0;i < n;i++) ret[i] = i+1;
return ret;
}
const int inf = 1e9;
int find_next_station(int s, int t, std::vector<int> c) {
auto d = [&] (int x) {
int ret = 0;
while (x) {
x>>=1;
ret++;
}
return ret;
};
if (t < s) {
for (int v:c) {
if (v < s) return v;
}
}
int dif = d(t) - d(s);
int tmp = t>>dif;
if (tmp != s) {
for (int v:c) {
if (v < s) return v;
}
} else {
int p = (t>>(dif-1)) & 1;
for (int v:c) {
if (v > s && (v&1) == p) return v;
}
}
return 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... |