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 <vector>
#include <iostream>
#include <cstring>
using namespace std;
vector<vector<int>> g(1000+10);
vector<int> l(10000 +10);
int spn = -1;
void dfs(int node, int i, int p)
{
l[node] = i;
for(int y : g[node])
{
if(y != p)
{
dfs(y, i+1, node);
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
vector<int> labels(n);
l.resize(n);
for(int i = 0; i < n-1; i++)
{
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
if(spn!= -1)
{
for(int i = 0; i < n; i++)
{
if(g[i].size() == 1)
{
spn = i;
break;
}
}}
dfs(spn, 0, -1);
//cout<<"hola"<<endl;
for (int i = 0; i < n; i++)
{
labels[i] = l[i];
//cout<<"l[i] "<<l[i]<<" lb i "<<labels[l[i]]<<endl;
}
//cout<<"---------"<<endl;
for(int i=0; i<n; i++) g[i].clear();
l.clear();
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
if(t>s)return s+1;
return s-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... |