#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> cnt;
vector<int> labels(n);
vector<vector<int>> graph(n, vector<int>());
for (int i = 0; i < n - 1; i++) {
cnt[u[i]]++;
cnt[v[i]]++;
graph[u[i]].pb(v[i]);
graph[v[i]].pb(u[i]);
}
int cur = 0;
for(int i =0; i <n; i++)
if(cnt[i] == 1) {
cur = i;
break;
}
vector<bool> vis(n);
int counter = 0;
while(true){
labels[cur] = counter++;
vis[cur] = true;
bool done = true;
for(int adj : graph[cur]){
if(vis[adj]) continue;
done = false;
cur = adj;
break;
}
if(done ) break;
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if(c.size() == 1) return c[0];
if( s < t) return c[1];
return c[0];
}
/************/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
284 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
276 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
276 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |