#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
const int mxN = 1010;
int dfs_timer = 0;
vi labels, adj[mxN];
void dfs(int s, int p, int dep){
if(!dep) labels[s] = dfs_timer++;
for(auto u : adj[s])
if(u!=p) dfs(u,s,dep^1);
if(dep) labels[s] = dfs_timer++;
}
vi label(int n, int k, vi u, vi v) {
labels.clear(); labels.resize(n,0); dfs_timer=0;
for(int i = 0; i < n; i++) adj[i].clear();
for(int i = 0; i < sz(u); i++){
int a = u[i], b = v[i];
adj[a].pb(b), adj[b].pb(a);
}
dfs(0,-1, 0); return labels;
}
int find_next_station(int s, int t, vi c) {
if(sz(c)==1) return c[0];
for(auto u : c) if(u==t) return u;
if(s < c[0]){
if(s<=t and t<=c.back())
return *lower_bound(all(c),t);
return c.back();
}
if(c[0]<=t and t<=s)
return *--upper_bound(all(c),t);
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
341 ms |
684 KB |
Output is correct |
2 |
Correct |
255 ms |
940 KB |
Output is correct |
3 |
Correct |
509 ms |
684 KB |
Output is correct |
4 |
Correct |
324 ms |
944 KB |
Output is correct |
5 |
Correct |
291 ms |
684 KB |
Output is correct |
6 |
Correct |
269 ms |
688 KB |
Output is correct |
7 |
Correct |
238 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
808 KB |
Output is correct |
9 |
Correct |
2 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
237 ms |
684 KB |
Output is correct |
2 |
Correct |
285 ms |
684 KB |
Output is correct |
3 |
Correct |
527 ms |
684 KB |
Output is correct |
4 |
Correct |
345 ms |
684 KB |
Output is correct |
5 |
Correct |
331 ms |
712 KB |
Output is correct |
6 |
Correct |
262 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
316 ms |
940 KB |
Output is correct |
2 |
Correct |
246 ms |
684 KB |
Output is correct |
3 |
Correct |
546 ms |
684 KB |
Output is correct |
4 |
Correct |
382 ms |
684 KB |
Output is correct |
5 |
Correct |
311 ms |
684 KB |
Output is correct |
6 |
Correct |
278 ms |
684 KB |
Output is correct |
7 |
Correct |
264 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
776 KB |
Output is correct |
9 |
Correct |
2 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
780 KB |
Output is correct |
11 |
Correct |
326 ms |
684 KB |
Output is correct |
12 |
Correct |
250 ms |
1044 KB |
Output is correct |
13 |
Correct |
281 ms |
684 KB |
Output is correct |
14 |
Correct |
246 ms |
684 KB |
Output is correct |
15 |
Correct |
21 ms |
1016 KB |
Output is correct |
16 |
Correct |
35 ms |
768 KB |
Output is correct |
17 |
Correct |
49 ms |
780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
480 ms |
684 KB |
Output is correct |
2 |
Correct |
336 ms |
684 KB |
Output is correct |
3 |
Correct |
349 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
764 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
764 KB |
Output is correct |
7 |
Correct |
339 ms |
756 KB |
Output is correct |
8 |
Correct |
453 ms |
688 KB |
Output is correct |
9 |
Correct |
415 ms |
684 KB |
Output is correct |
10 |
Correct |
293 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 |
768 KB |
Output is correct |
15 |
Correct |
0 ms |
768 KB |
Output is correct |
16 |
Correct |
300 ms |
684 KB |
Output is correct |
17 |
Correct |
277 ms |
684 KB |
Output is correct |
18 |
Correct |
287 ms |
684 KB |
Output is correct |
19 |
Correct |
280 ms |
684 KB |
Output is correct |
20 |
Correct |
290 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
319 ms |
684 KB |
Output is correct |
2 |
Correct |
247 ms |
688 KB |
Output is correct |
3 |
Correct |
529 ms |
684 KB |
Output is correct |
4 |
Correct |
401 ms |
708 KB |
Output is correct |
5 |
Correct |
318 ms |
936 KB |
Output is correct |
6 |
Correct |
233 ms |
684 KB |
Output is correct |
7 |
Correct |
250 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 |
768 KB |
Output is correct |
11 |
Correct |
279 ms |
688 KB |
Output is correct |
12 |
Correct |
286 ms |
684 KB |
Output is correct |
13 |
Correct |
491 ms |
684 KB |
Output is correct |
14 |
Correct |
379 ms |
684 KB |
Output is correct |
15 |
Correct |
318 ms |
684 KB |
Output is correct |
16 |
Correct |
249 ms |
684 KB |
Output is correct |
17 |
Correct |
340 ms |
684 KB |
Output is correct |
18 |
Correct |
244 ms |
796 KB |
Output is correct |
19 |
Correct |
254 ms |
788 KB |
Output is correct |
20 |
Correct |
257 ms |
684 KB |
Output is correct |
21 |
Correct |
28 ms |
776 KB |
Output is correct |
22 |
Correct |
32 ms |
764 KB |
Output is correct |
23 |
Correct |
44 ms |
772 KB |
Output is correct |
24 |
Correct |
2 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
768 KB |
Output is correct |
26 |
Correct |
2 ms |
768 KB |
Output is correct |
27 |
Correct |
1 ms |
772 KB |
Output is correct |
28 |
Correct |
0 ms |
768 KB |
Output is correct |
29 |
Correct |
269 ms |
684 KB |
Output is correct |
30 |
Correct |
288 ms |
684 KB |
Output is correct |
31 |
Correct |
276 ms |
680 KB |
Output is correct |
32 |
Correct |
298 ms |
684 KB |
Output is correct |
33 |
Correct |
259 ms |
684 KB |
Output is correct |
34 |
Correct |
188 ms |
684 KB |
Output is correct |
35 |
Correct |
255 ms |
1188 KB |
Output is correct |
36 |
Correct |
235 ms |
800 KB |
Output is correct |
37 |
Correct |
266 ms |
932 KB |
Output is correct |
38 |
Correct |
236 ms |
944 KB |
Output is correct |
39 |
Correct |
245 ms |
1196 KB |
Output is correct |
40 |
Correct |
224 ms |
792 KB |
Output is correct |
41 |
Correct |
284 ms |
1044 KB |
Output is correct |
42 |
Correct |
25 ms |
768 KB |
Output is correct |
43 |
Correct |
58 ms |
772 KB |
Output is correct |
44 |
Correct |
71 ms |
688 KB |
Output is correct |
45 |
Correct |
91 ms |
760 KB |
Output is correct |
46 |
Correct |
181 ms |
684 KB |
Output is correct |
47 |
Correct |
165 ms |
684 KB |
Output is correct |
48 |
Correct |
27 ms |
768 KB |
Output is correct |
49 |
Correct |
26 ms |
876 KB |
Output is correct |