#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(n);
vector<int> labels(n);
vector<vector<int>> graph(n, vector<int>());
for (int i = 0; i < n - 1; i++) {
//cout << u[i]<<", "<<v[i]<<endl;
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++;
//cout << cur <<", "<<counter<<endl;
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 |
Correct |
697 ms |
484 KB |
Output is correct |
2 |
Correct |
515 ms |
540 KB |
Output is correct |
3 |
Correct |
1043 ms |
468 KB |
Output is correct |
4 |
Correct |
776 ms |
484 KB |
Output is correct |
5 |
Correct |
976 ms |
528 KB |
Output is correct |
6 |
Correct |
588 ms |
476 KB |
Output is correct |
7 |
Correct |
680 ms |
472 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
284 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
707 ms |
528 KB |
Output is correct |
2 |
Correct |
515 ms |
484 KB |
Output is correct |
3 |
Correct |
1105 ms |
400 KB |
Output is correct |
4 |
Correct |
810 ms |
488 KB |
Output is correct |
5 |
Correct |
736 ms |
488 KB |
Output is correct |
6 |
Correct |
530 ms |
480 KB |
Output is correct |
7 |
Correct |
518 ms |
484 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
6 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Incorrect |
1 ms |
200 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1144 ms |
400 KB |
Output is correct |
2 |
Correct |
793 ms |
400 KB |
Output is correct |
3 |
Correct |
635 ms |
500 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
6 ms |
464 KB |
Output is correct |
6 |
Correct |
2 ms |
476 KB |
Output is correct |
7 |
Incorrect |
1 ms |
200 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
715 ms |
484 KB |
Output is correct |
2 |
Correct |
608 ms |
480 KB |
Output is correct |
3 |
Correct |
1128 ms |
400 KB |
Output is correct |
4 |
Correct |
954 ms |
492 KB |
Output is correct |
5 |
Correct |
685 ms |
528 KB |
Output is correct |
6 |
Correct |
624 ms |
520 KB |
Output is correct |
7 |
Correct |
632 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
420 KB |
Output is correct |
9 |
Correct |
7 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Incorrect |
6 ms |
356 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |