#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> ipii;
const int MAXN = 1e3+10;
const int MAX = 1e3;
int n, k;
vector <int> adj[MAXN], dw[MAXN];
vector <int> lab;
int cnt;
void dfs(int nw, int par, int dep){ // build val, tergantung dfs
if(dep%2 == 0) lab[nw] = cnt++;
for(auto nx : adj[nw]){
if(nx == par) continue;
dfs(nx, nw, dep+1);
}
if(dep%2) lab[nw] = cnt++;
}
vector<int> label(int N, int K, vector<int> u, vector<int> v) {
n = N; k = K;
lab.clear(); lab.resize(n); cnt = 0;
for(int i=0; i<=n; i++){
adj[i].clear(); dw[i].clear();
}
for(int i=0; i<n-1; i++){
adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]);
}
dfs(0, -1, 0);
//for(int i=0; i<n; i++) cout << i << ' '<< lab[i] << " p\n";
return lab;
}
int find_next_station(int s, int t, vector<int> c) { // c sorted
if(s < c[0]){ // dep[s] = 0
if(t<s || t>=c.back()) return c.back(); // parent --> max
return *lower_bound(c.begin(), c.end(), t);
}
if(t>s || t<=c.front()) return c.front();
auto it = upper_bound(c.begin(), c.end(), t);
it--;
return *(it);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
353 ms |
948 KB |
Output is correct |
2 |
Correct |
308 ms |
960 KB |
Output is correct |
3 |
Correct |
594 ms |
684 KB |
Output is correct |
4 |
Correct |
400 ms |
684 KB |
Output is correct |
5 |
Correct |
383 ms |
936 KB |
Output is correct |
6 |
Correct |
274 ms |
944 KB |
Output is correct |
7 |
Correct |
314 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
3 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
285 ms |
892 KB |
Output is correct |
2 |
Correct |
320 ms |
832 KB |
Output is correct |
3 |
Correct |
612 ms |
684 KB |
Output is correct |
4 |
Correct |
413 ms |
936 KB |
Output is correct |
5 |
Correct |
387 ms |
936 KB |
Output is correct |
6 |
Correct |
272 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
342 ms |
960 KB |
Output is correct |
2 |
Correct |
266 ms |
964 KB |
Output is correct |
3 |
Correct |
490 ms |
840 KB |
Output is correct |
4 |
Correct |
365 ms |
684 KB |
Output is correct |
5 |
Correct |
336 ms |
860 KB |
Output is correct |
6 |
Correct |
267 ms |
932 KB |
Output is correct |
7 |
Correct |
264 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
764 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
363 ms |
1076 KB |
Output is correct |
12 |
Correct |
258 ms |
1016 KB |
Output is correct |
13 |
Correct |
265 ms |
1340 KB |
Output is correct |
14 |
Correct |
308 ms |
684 KB |
Output is correct |
15 |
Correct |
31 ms |
768 KB |
Output is correct |
16 |
Correct |
40 ms |
944 KB |
Output is correct |
17 |
Correct |
54 ms |
964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
510 ms |
684 KB |
Output is correct |
2 |
Correct |
366 ms |
684 KB |
Output is correct |
3 |
Correct |
317 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
357 ms |
684 KB |
Output is correct |
8 |
Correct |
586 ms |
684 KB |
Output is correct |
9 |
Correct |
348 ms |
684 KB |
Output is correct |
10 |
Correct |
361 ms |
684 KB |
Output is correct |
11 |
Correct |
3 ms |
764 KB |
Output is correct |
12 |
Correct |
4 ms |
772 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
764 KB |
Output is correct |
15 |
Correct |
0 ms |
768 KB |
Output is correct |
16 |
Correct |
346 ms |
684 KB |
Output is correct |
17 |
Correct |
259 ms |
684 KB |
Output is correct |
18 |
Correct |
294 ms |
684 KB |
Output is correct |
19 |
Correct |
299 ms |
684 KB |
Output is correct |
20 |
Correct |
303 ms |
696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
318 ms |
948 KB |
Output is correct |
2 |
Correct |
228 ms |
1076 KB |
Output is correct |
3 |
Correct |
584 ms |
684 KB |
Output is correct |
4 |
Correct |
465 ms |
684 KB |
Output is correct |
5 |
Correct |
398 ms |
684 KB |
Output is correct |
6 |
Correct |
305 ms |
956 KB |
Output is correct |
7 |
Correct |
275 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
772 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
247 ms |
884 KB |
Output is correct |
12 |
Correct |
327 ms |
864 KB |
Output is correct |
13 |
Correct |
624 ms |
1188 KB |
Output is correct |
14 |
Correct |
464 ms |
684 KB |
Output is correct |
15 |
Correct |
355 ms |
944 KB |
Output is correct |
16 |
Correct |
298 ms |
684 KB |
Output is correct |
17 |
Correct |
329 ms |
684 KB |
Output is correct |
18 |
Correct |
345 ms |
1052 KB |
Output is correct |
19 |
Correct |
293 ms |
1584 KB |
Output is correct |
20 |
Correct |
305 ms |
684 KB |
Output is correct |
21 |
Correct |
33 ms |
768 KB |
Output is correct |
22 |
Correct |
38 ms |
856 KB |
Output is correct |
23 |
Correct |
60 ms |
880 KB |
Output is correct |
24 |
Correct |
2 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
776 KB |
Output is correct |
26 |
Correct |
2 ms |
768 KB |
Output is correct |
27 |
Correct |
3 ms |
768 KB |
Output is correct |
28 |
Correct |
1 ms |
768 KB |
Output is correct |
29 |
Correct |
339 ms |
684 KB |
Output is correct |
30 |
Correct |
291 ms |
684 KB |
Output is correct |
31 |
Correct |
289 ms |
684 KB |
Output is correct |
32 |
Correct |
301 ms |
936 KB |
Output is correct |
33 |
Correct |
328 ms |
684 KB |
Output is correct |
34 |
Correct |
190 ms |
932 KB |
Output is correct |
35 |
Correct |
279 ms |
1476 KB |
Output is correct |
36 |
Correct |
263 ms |
1068 KB |
Output is correct |
37 |
Correct |
276 ms |
1168 KB |
Output is correct |
38 |
Correct |
252 ms |
1164 KB |
Output is correct |
39 |
Correct |
318 ms |
1180 KB |
Output is correct |
40 |
Correct |
287 ms |
1060 KB |
Output is correct |
41 |
Correct |
267 ms |
1296 KB |
Output is correct |
42 |
Correct |
35 ms |
956 KB |
Output is correct |
43 |
Correct |
52 ms |
1156 KB |
Output is correct |
44 |
Correct |
77 ms |
940 KB |
Output is correct |
45 |
Correct |
99 ms |
936 KB |
Output is correct |
46 |
Correct |
165 ms |
888 KB |
Output is correct |
47 |
Correct |
185 ms |
916 KB |
Output is correct |
48 |
Correct |
34 ms |
1252 KB |
Output is correct |
49 |
Correct |
31 ms |
1456 KB |
Output is correct |