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 sz(x) (int)x.size()
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define lowb(x) (x&(-x))
#define ALL(_x) _x.begin(),_x.end()
#define pii pair<int,int>
#define f first
#define s second
#define SORT_UNIQUE(x) sort(ALL(x)),x.erase(unique(ALL(x)),x.end())
#define ll long long
#define MNTO(x,y) x=min(x,y)
#define MXTO(x,y) x=max(x,y)
const int maxn=2e5+5;
const int INF=0x3f3f3f3f;
int dep[maxn];
vector<int> g[maxn];
int in[maxn],out[maxn];
int cur=0;
void dfs(int u,int p){
in[u]=(cur++);
for(int x:g[u]){
if(x==p) continue;
dep[x]=dep[u]+1;
dfs(x,u);
}
out[u]=(cur++);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
cur=0;
REP(i,n-1){
g[u[i]].pb(v[i]),g[v[i]].pb(u[i]);
}
dfs(0,-1);
vector<int> ans;
REP(i,n){
if(dep[i]%2) ans.pb(in[i]);
else ans.pb(out[i]);
}
return ans;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s<c[0]){
c.emplace(c.begin(),s);
//s labeled in
REP1(i,sz(c)-1){
if(t<=c[i] and t>c[i-1]){
return c[i];
}
}
return c.back();
}
else{
REP1(i,sz(c)-1){
if(t<=c[i] and t>c[i-1]){
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... |