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;
vector <int> grafo[1003];
int arr[1003];
bool vis[1003];
void dfs(int node,int c){
vis[node]=true,arr[node]=c;
for(auto i:grafo[node]) if(!vis[i]) dfs(i,c+1);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i=0;i<n;i++) grafo[i].clear();
for(int i=0;i<n-1;i++){
grafo[u[i]].push_back(v[i]);
grafo[v[i]].push_back(u[i]);
}
int node=0;
for(int i=0;i<n;i++) if(grafo[i].size()>2) node=i;
fill(vis,vis+n+1,false);
fill(arr,arr+n+1,0);
vis[node]=true,arr[node]=0;
int a=1;
for(auto i:grafo[node]) dfs(i,a),a+=1000;
vector <int> solve;
for(int i=0;i<n;i++) solve.push_back(arr[i]);
return solve;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.size()==1) return c[0];
if(c.size()==2){
if(s/1000!=t/1000) return c[0];
if(s<t) return c[1];
return c[0];
}
return t/1000*1000+1;
}
# | 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... |