This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//by szh
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
#include "stations.h"
int dfs(int u,int pos,int flag,int lst,vector <int> &l,vector <vector<int>> edge) {
int ret = pos;
if (flag==1) l[u] = pos++;
for (int v:edge[u]) {
if (v==lst) continue;
int tmp = dfs(v,pos,flag^1,u,l,edge);
pos += tmp;
}
if (flag==0) l[u] = pos++;
// debug(233),cout<<u<<" "<<l[u]<<endl;
return pos-ret;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector <int> ans(n);
vector <vector<int>> edge(n);
rep(i,0,n-1) {
edge[u[i]].pb(v[i]);
edge[v[i]].pb(u[i]);
}
dfs(0,0,0,-1,ans,edge);
return ans;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (SZ(c)==1) return c[0];
if (c.back()<s) {
rep(i,1,SZ(c)-1) {
if (t>=c[i] and t<c[i+1]) return c[i];
}
if (t>=c.back() and t<s) return c.back();
return c[0];
}
else {
assert(c[0]>s);
if (t>s and t<=c[0]) return c[0];
rep(i,1,SZ(c)-1) if (t>c[i-1] and t<=c[i]) return c[i];
return c.back();
}
}
# | 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... |