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;
#define MAXI (int)1e3+10
vector<int> ad[MAXI];
vector<int> labels;
// 1 .. 1e3
// 1e3+1 ... 2e3
void dfs(int x,int e){
if(e > 0){
labels[x] = labels[e]+1;
}
int cnt = 0;
for(auto s: ad[x]){
if(s == e) continue;
if(x == 0 && e == -1){
labels[s] = cnt*1000;
cnt++;
}
dfs(s,x);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
labels.assign(n,0);
for(int i = 0;i<MAXI;i++) ad[i].clear();
for(int i = 0;i<n-1;i++){
ad[u[i]].push_back(v[i]);
ad[v[i]].push_back(u[i]);
}
int start = 0;
for(int i = 0;i<n;i++){
if(ad[i].size() >= 3){
start = i;
break;
}
}
labels[start] = 1e6;
dfs(start,-1);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s == 1e6){
for(int i = 0;i<(int)c.size();i++){
if(abs(c[i]-t) < (int)1e3) return c[i];
}
}else{
if((s/1000)*1000 == (t/1000)*1000){
return t > s ? c[1] : c[0];
}else return c[0];
}
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... |