#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
vector<int> g[n + 7];
for(int i = 0; i < n - 1; i++){
int x = u[i], y = v[i];
g[x].push_back(y);
g[y].push_back(x);
}
int st = 0;
for(int i = 1; i < n; i++){
if((int)g[i].size() < (int)g[st].size()){
st = i;
}
}
queue<int> q;
q.push(st);
vector<int> d(n + 7, 1e9);
d[st] = 0;
while(!q.empty()){
int x = q.front();
q.pop();
for(auto y : g[x]){
if(d[y] == 1e9){
d[y] = d[x] + 1;
q.push(y);
}
}
}
for(int i = 0; i < n; i++){
labels[i] = d[i];
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
for(auto x : c){
if(s < t && x > s)return x;
if(s > t && x < s)return x;
}
return c[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
988 ms |
484 KB |
Output is correct |
2 |
Correct |
751 ms |
540 KB |
Output is correct |
3 |
Correct |
1557 ms |
420 KB |
Output is correct |
4 |
Correct |
1700 ms |
488 KB |
Output is correct |
5 |
Correct |
703 ms |
400 KB |
Output is correct |
6 |
Correct |
612 ms |
548 KB |
Output is correct |
7 |
Correct |
922 ms |
520 KB |
Output is correct |
8 |
Correct |
4 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
524 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
284 KB |
Invalid labels (duplicates values). scenario=0, label=10 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
908 ms |
568 KB |
Output is correct |
2 |
Correct |
749 ms |
524 KB |
Output is correct |
3 |
Correct |
1583 ms |
448 KB |
Output is correct |
4 |
Correct |
1103 ms |
484 KB |
Output is correct |
5 |
Correct |
1152 ms |
472 KB |
Output is correct |
6 |
Correct |
822 ms |
644 KB |
Output is correct |
7 |
Correct |
739 ms |
596 KB |
Output is correct |
8 |
Correct |
3 ms |
480 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Incorrect |
1 ms |
288 KB |
Invalid labels (duplicates values). scenario=1, label=2 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1418 ms |
464 KB |
Output is correct |
2 |
Correct |
1008 ms |
548 KB |
Output is correct |
3 |
Correct |
932 ms |
484 KB |
Output is correct |
4 |
Correct |
5 ms |
532 KB |
Output is correct |
5 |
Correct |
7 ms |
540 KB |
Output is correct |
6 |
Correct |
3 ms |
468 KB |
Output is correct |
7 |
Incorrect |
1 ms |
200 KB |
Invalid labels (duplicates values). scenario=0, label=2 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
773 ms |
596 KB |
Output is correct |
2 |
Correct |
793 ms |
604 KB |
Output is correct |
3 |
Correct |
1482 ms |
472 KB |
Output is correct |
4 |
Correct |
852 ms |
404 KB |
Output is correct |
5 |
Correct |
1212 ms |
476 KB |
Output is correct |
6 |
Correct |
788 ms |
488 KB |
Output is correct |
7 |
Correct |
671 ms |
484 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
476 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Incorrect |
7 ms |
288 KB |
Invalid labels (duplicates values). scenario=0, label=10 |
12 |
Halted |
0 ms |
0 KB |
- |