#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
map<int, vector<int>> graph;
vector<int> labels;
int times;
void dfs(int node, int parent, int depth)
{
    if ((depth )%2==1)
    {
        labels[node] = ++times;
    }
    for (int i:graph[node])
    {
        if (i!=parent)
        {
            dfs(i,node,depth+1);       
        }
    }
    if ((depth )%2==0)
    { 
        labels[node] = ++times;
    }
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	times = -1;
    labels.resize(n);
    for (int i=0;i<n-1; i++)
    {
        graph[u[i]].push_back(v[i]);
        graph[v[i]].push_back(u[i]);
    }
    
    dfs(1,-1,0);
    graph.clear();
    return labels;
}
int find_next_station(int s, int t, std::vector<int> c) 
{
  int n = c.size();
    if (n==1) return c[0];
    
    if (s >= c[0])
    {
        if (t> s) return c[0];
      for (int i=n-1;i>=0;i--)
      {
        if (c[i] <= t )
        {
          return c[i];
        }
      }
    }
    else
    {
        if (t < s) return c[n-1];
        for (int i=0;i<n;i++)
        {
            if (c[i] >= t )
            {
            return c[i];
            }
        }
        return c.back();
    }
    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... |