#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
bool line = 1;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<vector<int>> adj(n);
for (int i = 0; i < n-1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
int r = -1;
for (int i = 0; i < n; i++) {
if (adj[i].size() == 1) r = i;
line &= adj[i].size() <= 2;
}
if (line) {
vector<int> ans(n);
int t = 0;
auto dfs = [&](auto&& s, int v, int p) -> void {
ans[v] = t++;
for (int u : adj[v]) if (u != p) s(s, u, v);
};
dfs(dfs, r, -1);
return ans;
}
return {};
}
int find_next_station(int s, int t, std::vector<int> c) {
for (int x : c) if ((x-s)*(x-t) <= 0) return x;
assert(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
306 ms |
684 KB |
Output is correct |
2 |
Correct |
265 ms |
684 KB |
Output is correct |
3 |
Correct |
417 ms |
684 KB |
Output is correct |
4 |
Correct |
344 ms |
684 KB |
Output is correct |
5 |
Correct |
348 ms |
684 KB |
Output is correct |
6 |
Correct |
233 ms |
684 KB |
Output is correct |
7 |
Correct |
243 ms |
684 KB |
Output is correct |
8 |
Correct |
0 ms |
776 KB |
Output is correct |
9 |
Correct |
1 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Invalid length of array as the response of 'label'. scenario=0, n=996, len=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
308 ms |
684 KB |
Output is correct |
2 |
Correct |
240 ms |
684 KB |
Output is correct |
3 |
Correct |
557 ms |
684 KB |
Output is correct |
4 |
Correct |
386 ms |
684 KB |
Output is correct |
5 |
Correct |
330 ms |
684 KB |
Output is correct |
6 |
Correct |
258 ms |
684 KB |
Output is correct |
7 |
Correct |
246 ms |
684 KB |
Output is correct |
8 |
Correct |
0 ms |
764 KB |
Output is correct |
9 |
Correct |
1 ms |
788 KB |
Output is correct |
10 |
Correct |
0 ms |
776 KB |
Output is correct |
11 |
Incorrect |
0 ms |
344 KB |
Invalid length of array as the response of 'label'. scenario=1, n=4, len=0 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
499 ms |
684 KB |
Output is correct |
2 |
Correct |
372 ms |
684 KB |
Output is correct |
3 |
Correct |
318 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
772 KB |
Output is correct |
6 |
Correct |
0 ms |
776 KB |
Output is correct |
7 |
Incorrect |
0 ms |
344 KB |
Invalid length of array as the response of 'label'. scenario=0, n=4, len=0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
263 ms |
684 KB |
Output is correct |
2 |
Correct |
234 ms |
684 KB |
Output is correct |
3 |
Correct |
499 ms |
684 KB |
Output is correct |
4 |
Correct |
400 ms |
684 KB |
Output is correct |
5 |
Correct |
329 ms |
684 KB |
Output is correct |
6 |
Correct |
272 ms |
684 KB |
Output is correct |
7 |
Correct |
255 ms |
680 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
780 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Incorrect |
0 ms |
344 KB |
Invalid length of array as the response of 'label'. scenario=0, n=997, len=0 |
12 |
Halted |
0 ms |
0 KB |
- |