이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
const int maxn=1e3+9;
vector<int>a[maxn],in,dep;
int tme=0;
void dfs(int u,int par){
if (dep[u]%2==0)in[u]=++tme;
for (auto v:a[u]){
if (v==par)continue;
dep[v]=dep[u]+1;
dfs(v,u);
}
if (dep[u]%2==1)in[u]=++tme;
in[u]--;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for1(i,0,n-1)a[i].clear();
for1(i,0,n-2)a[u[i]].pb(v[i]),a[v[i]].pb(u[i]);
in.resize(n),dep.resize(n);
tme=0;
dfs(0,0);
return in;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (sz(c)==1)return c[0];
if (s>c[0]){//dep 1
if (t>=c[1]&&t<=s){
for1(i,0,sz(c)-2){
if (t>=c[i]&&t<=c[i+1]-1)return c[i];
}
return c.back();
}
else return c[0];
}
else {//dep 0
if (s==0){
for1(i,sz(c)-1,1){
if (c[i-1]+1<=t&&t<=c[i])return c[i];
}
return c[0];
}
if (t>=s&&t<=c[sz(c)-2]){
for1(i,sz(c)-2,1){
if (c[i-1]+1<=t&&t<=c[i])return c[i];
}
return c[0];
}
else {
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... |