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 dbgv(v) cout<<#v<<" = "; f(i,0,int(v.size())) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
const int N=1000;
int Time,st[N],ft[N];
vector<int> g[N];
void dfs(int u,int p){
st[u]=Time++;
for(auto v : g[u]){
if(v==p) continue ;
dfs(v,u);
}
ft[u]=Time;
}
vector<int> label(int n, int k,vector<int> u,vector<int> v) {
vector<int> labels(n);
Time=0;
f(i,0,n) g[i].clear();
f(i,0,n-1) g[u[i]].pb(v[i]),g[v[i]].pb(u[i]);
dfs(0,0);
f(i,0,n){
labels[i]=st[i]*N+ft[i]-1;
//cout<<i<<" -> "<<labels[i]<<'\n';
}
return labels;
}
int St(int u){
return u/N;
}
int Ft(int u){
return u%N+1;
}
int is_par(int u,int v){
return St(u)<=St(v) && St(v)<Ft(u);
}
int find_next_station(int s, int t,vector<int> c) {
//cout<<s<<" --- "<<t<<endl;
if(is_par(s,t)){
for(auto v : c){
if(is_par(s,v) && is_par(v,t)){
return v;
}
}
}
for(auto v : c){
if(is_par(v,s)){
return v;
}
}
//assert(0);
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... |