#include "stations.h"
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define str string
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define pii pair<int,int>
#define vl vector<ll>
#define vll vector<pll>
#define vlll vector<plll>
#define vllll vector<p4>
#define vi vector<int>
#define vii vector<pii>
#define sz(x) (ll)(x).size()
#define fr front()
#define tp top()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ins insert
#define m_p make_pair
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
using namespace std;
const ld pi=acos(-1.0);
const ll e5=1e5, e6=1e6, e9=1e9;
const ll inf=1e18;
const ll mod=998244353;
const ll MOD=106710087877475399;
const ll N=1e3+10;
const ll M=2e5+10;
const ld eps=1e-9;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll bpm(ll x,ll y,ll m){if(y==0)return 1%m;ll p=bpm(x,y/2,m);
if(y%2==0)return p*p%m;else return p*p%m*x%m;}
ll bp(ll x,ll y){if(y==0)return 1;ll p=bp(x,y/2);
if(y%2==0)return p*p;else return p*p*x;}
vi g[N];
int d[N],T,l[N];
void dfs(int v,int p){
if(d[v]%2==0) l[v]=T++;
for(ll to:g[v]){
if(to==p) continue;
d[to]=d[v]+1;
dfs(to,v);
}
if(d[v]%2==1) l[v]=T++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i=0;i<n;i++) g[i].clear();
for(int i=0;i<n-1;i++){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
d[0]=0;
T=0;
dfs(0,-1);
std::vector<int> labels(n);
for(int i=0;i<n;i++) labels[i]=l[i];
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
int n=sz(c)-1;
if(n==0) return c[0];
if(s<c[0]){
if(s<=t&&t<=c[0]) return c[0];
for(int i=1;i<n;i++){
if(c[i-1]<t&&t<=c[i]) return c[i];
}
return c[n];
}else{
if(c[n]<=t&&t<=s) return c[n];
for(int i=n-1;i>0;i--){
if(c[i]<=t&&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... |