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 pb push_back
const int N = 1e3 + 10;
int t=-1;
vector<int> ans,adj[N];
void dfs(int v, int p, int c){
if(!c) ans[v]=++t;
for(int u : adj[v]) if(u!=p) dfs(u,v,1-c);
if(c) ans[v]=++t;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
ans.resize(n);
for(int i=0; i<(int)v.size(); i++){
adj[v[i]].pb(u[i]);
adj[u[i]].pb(v[i]);
}
dfs(0,-1,0);
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
int k;
if(s<c[0]){
k=c.back();
if(s) c.pop_back();
if(t<s || t>c.back()) return k;
return *lower_bound(c.begin(),c.end(),t);
}else{
k=c[0];
c.erase(c.begin());
if(t<c[0] || t>s) return k;
return *(upper_bound(c.begin(),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... |