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>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
typedef std::pair<ll,ll> pll;
using namespace std;
const int N = 1024;
vector<int> A[N];
int ans[N];
void dfs(int v, int p, int &t, int c)
{
if (!c)
ans[v] = t++;
for (int u : A[v])
if (u != p)
dfs(u, v, t, !c);
if (c)
ans[v] = t++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
Loop (i,0,n-1) {
int x = v[i], y = u[i];
A[x].push_back(y);
A[y].push_back(x);
}
int dard = 0;
dfs(0, -1, dard, 0);
return vector<int>(ans, ans+n);
}
int find_next_station(int s, int t, std::vector<int> c) {
sort(c.begin(), c.end());
if (s == 0)
return *lower_bound(c.begin(), c.end(), t);
if (c[0] > s) {
if (t < s || t > c.end()[-2])
return c.back();
return *lower_bound(c.begin(), c.end()-1, t);
} else {
if (t > s || t < c[1])
return c[0];
return *(upper_bound(c.begin()+1, c.end(), t) - 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... |