#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
using ll = long long;
ll n, m, q, k, x, y, a, b, c;
vector<ll> G[1000];
void dfs(ll x, ll p, ll depth, ll &timer, vector<int> &ans) {
// cout << x << ' ' << p << ' ' << depth << ' ' << timer << endl;
if (depth % 2 == 0) {
ans[x] = timer;
}
timer++;
for (int i : G[x]) {
if (i != p) {
dfs(i, x, depth + 1, timer, ans);
}
}
if (depth % 2 == 1) {
ans[x] = timer;
}
timer++;
}
vector<int> label(int N, int K, vector<int> u, vector<int> v) {
n = N;
k = K;
for (int i = 0; i < 1000; i++) {
G[i].clear();
}
for (int i = 0; i < u.size(); i++) {
G[u[i]].push_back(v[i]);
G[v[i]].push_back(u[i]);
}
vector<int> ans(n);
ll timer = 0;
dfs(0, -1, 0, timer, ans);
// for (int i = 0; i < n; i++) {
// cout << ans[i] << ' ';
// }
// cout << endl;
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
// cout << s << ' ' << t << '\n';
// for (int i = 0; i < c.size(); i++) {
// cout << c[i] << ' ';
// }
// cout << '\n';
if (s > c[c.size() - 1]) {
for (int i = 1; i < c.size(); i++) {
if (c[i] > t) {
return c[i - 1];
}
}
if (s > t) {
return c[c.size() - 1];
}
return c[0];
}
if (s > t) {
return c[c.size() - 1];
}
for (int i = 0; i < c.size() - 1; i++) {
if (c[i] >= t) {
return c[i];
}
}
return c[c.size() - 1];
}
Compilation message
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i = 0; i < u.size(); i++) {
| ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:54:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for (int i = 1; i < c.size(); i++) {
| ~~^~~~~~~~~~
stations.cpp:67:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for (int i = 0; i < c.size() - 1; i++) {
| ~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
374 ms |
684 KB |
Output is correct |
2 |
Correct |
310 ms |
684 KB |
Output is correct |
3 |
Correct |
549 ms |
684 KB |
Output is correct |
4 |
Correct |
431 ms |
684 KB |
Output is correct |
5 |
Correct |
359 ms |
684 KB |
Output is correct |
6 |
Correct |
323 ms |
684 KB |
Output is correct |
7 |
Correct |
309 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
776 KB |
Output is correct |
11 |
Correct |
407 ms |
684 KB |
Output is correct |
12 |
Correct |
324 ms |
1060 KB |
Output is correct |
13 |
Correct |
360 ms |
1024 KB |
Output is correct |
14 |
Correct |
329 ms |
684 KB |
Output is correct |
15 |
Correct |
32 ms |
768 KB |
Output is correct |
16 |
Correct |
31 ms |
776 KB |
Output is correct |
17 |
Correct |
61 ms |
684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
614 ms |
684 KB |
Output is correct |
2 |
Correct |
482 ms |
684 KB |
Output is correct |
3 |
Correct |
431 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
780 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
776 KB |
Output is correct |
7 |
Correct |
392 ms |
684 KB |
Output is correct |
8 |
Correct |
574 ms |
684 KB |
Output is correct |
9 |
Correct |
466 ms |
940 KB |
Output is correct |
10 |
Correct |
412 ms |
684 KB |
Output is correct |
11 |
Correct |
3 ms |
768 KB |
Output is correct |
12 |
Correct |
3 ms |
768 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
1 ms |
764 KB |
Output is correct |
15 |
Correct |
0 ms |
780 KB |
Output is correct |
16 |
Correct |
355 ms |
680 KB |
Output is correct |
17 |
Correct |
367 ms |
684 KB |
Output is correct |
18 |
Correct |
363 ms |
684 KB |
Output is correct |
19 |
Correct |
375 ms |
684 KB |
Output is correct |
20 |
Correct |
340 ms |
684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
373 ms |
928 KB |
Partially correct |
2 |
Partially correct |
288 ms |
920 KB |
Partially correct |
3 |
Correct |
667 ms |
684 KB |
Output is correct |
4 |
Correct |
474 ms |
684 KB |
Output is correct |
5 |
Correct |
395 ms |
684 KB |
Output is correct |
6 |
Partially correct |
299 ms |
932 KB |
Partially correct |
7 |
Partially correct |
305 ms |
688 KB |
Partially correct |
8 |
Correct |
1 ms |
764 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
764 KB |
Output is correct |
11 |
Partially correct |
366 ms |
800 KB |
Partially correct |
12 |
Partially correct |
382 ms |
684 KB |
Partially correct |
13 |
Correct |
668 ms |
684 KB |
Output is correct |
14 |
Correct |
480 ms |
684 KB |
Output is correct |
15 |
Correct |
417 ms |
684 KB |
Output is correct |
16 |
Partially correct |
272 ms |
684 KB |
Partially correct |
17 |
Correct |
421 ms |
684 KB |
Output is correct |
18 |
Partially correct |
310 ms |
784 KB |
Partially correct |
19 |
Partially correct |
313 ms |
1180 KB |
Partially correct |
20 |
Partially correct |
279 ms |
684 KB |
Partially correct |
21 |
Correct |
37 ms |
768 KB |
Output is correct |
22 |
Partially correct |
36 ms |
684 KB |
Partially correct |
23 |
Partially correct |
59 ms |
684 KB |
Partially correct |
24 |
Correct |
2 ms |
768 KB |
Output is correct |
25 |
Correct |
3 ms |
768 KB |
Output is correct |
26 |
Correct |
3 ms |
776 KB |
Output is correct |
27 |
Correct |
2 ms |
768 KB |
Output is correct |
28 |
Correct |
0 ms |
768 KB |
Output is correct |
29 |
Correct |
348 ms |
684 KB |
Output is correct |
30 |
Correct |
338 ms |
684 KB |
Output is correct |
31 |
Correct |
333 ms |
684 KB |
Output is correct |
32 |
Correct |
361 ms |
684 KB |
Output is correct |
33 |
Correct |
378 ms |
684 KB |
Output is correct |
34 |
Partially correct |
214 ms |
684 KB |
Partially correct |
35 |
Partially correct |
292 ms |
928 KB |
Partially correct |
36 |
Partially correct |
308 ms |
932 KB |
Partially correct |
37 |
Partially correct |
328 ms |
932 KB |
Partially correct |
38 |
Partially correct |
308 ms |
936 KB |
Partially correct |
39 |
Partially correct |
278 ms |
1184 KB |
Partially correct |
40 |
Partially correct |
305 ms |
788 KB |
Partially correct |
41 |
Partially correct |
326 ms |
1188 KB |
Partially correct |
42 |
Partially correct |
35 ms |
768 KB |
Partially correct |
43 |
Partially correct |
56 ms |
744 KB |
Partially correct |
44 |
Partially correct |
77 ms |
688 KB |
Partially correct |
45 |
Partially correct |
107 ms |
956 KB |
Partially correct |
46 |
Partially correct |
188 ms |
684 KB |
Partially correct |
47 |
Partially correct |
214 ms |
684 KB |
Partially correct |
48 |
Partially correct |
32 ms |
1024 KB |
Partially correct |
49 |
Partially correct |
36 ms |
1340 KB |
Partially correct |