#include "stations.h"
#include <vector>
#include <iostream>
using namespace std;
vector<vector<int>> g(1010);
vector<int> l(1010);
bool ch[1010];
void dfs(int node, int i)
{
//if(ch[node])return;
ch[node]=true;
l[i] = node;
//cout<<node<<endl;
for(int y : g[node])
{
if(!ch[y])
{
dfs(y, i+1);
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
for(int i = 0; i < n-1; i++)
{
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
int spn = 0;
for(int i = 0; i < n; i++)
{
if(g[i].size() == 1)
{
spn = i;
break;
}
}
//dfs(spn, 0);//cout<<"hola"<<endl;
for (int i = 0; i < n; i++) {
labels[/*l[*/i/*]*/] = i;
//cout<<"l[i] "<<l[i]<<" i "<<i<<endl;
}
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
if(t>s)return s+1;
return s-1;
}
int main()
{
vector<int> u = {4, 9, 2, 5, 8, 1, 8, 6, 3};
vector<int> v = {5, 0, 6, 2, 3, 4, 1, 0, 7};
vector<int> labell(10);
labell = label(10, 10, u, v);
cout<<"hello"<<endl;
cout<<find_next_station(1, 3, {0, 2})<<endl;
}
Compilation message
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:32:6: warning: variable 'spn' set but not used [-Wunused-but-set-variable]
32 | int spn = 0;
| ^~~
/usr/bin/ld: /tmp/ccQkQbpb.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccRv84m8.o:stations.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status