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<bits/stdc++.h>
#include "stations.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
vector<int>label(int n,int k,vector<int>u,vector<int>v){
vector<int>l(n);
vector<int>adj[n];
for(int i=0;i<n-1;i++){
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
int mx=0,root=0;
for(int i=0;i<n;i++){
if((int)adj[i].size()>mx){
mx=(int)adj[i].size();
root=i;
}
}
int cur=0,g=0;
function <void(int,int)> dfs=[&](int x,int p){
l[x]=g*1000+cur;
cur++;
for(auto y:adj[x]){
if(y!=p){
dfs(y,x);
}
}
};
for(auto j:adj[root]){
g++;
cur=0;
dfs(j,root);
}
return l;
}
int find_next_station(int s,int t,vector<int>c){
if(s==0){
int ans=c[0];
for(int i:c){
if(i/1000==t/1000){
ans=i;
break;
}
}
return ans;
}
int g1=s/1000,g2=t/1000;
if(g1!=g2){
return c[0];
}
if(t<s) return c[0];
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... |