#include "stations.h"
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
typedef long long ll;
vector<int> v[1005];
int ti=0,ttin[1005],ttout[1005],depth[1005];
void dfs(int c,int p){
depth[c]=depth[p]^1;
ttin[c]=++ti;
for(int x:v[c]){
if(x==p) continue;
dfs(x,c);
}
ttout[c]=++ti;
}
vector<int> label(int n,int k,vector<int> u,vector<int> w){
depth[0]=ti=0;
for(int i=0;i<n;i++) v[i].clear();
vector<int> res(n);
for(int i=0;i<sz(u);i++){
v[u[i]].pb(w[i]);
v[w[i]].pb(u[i]);
}
dfs(0,0);
for(int i=0;i<n;i++){
if(depth[i]) res[i]=ttin[i];
else res[i]=ttout[i];
}
map<int,int> mp;
int fl=0;
for(int i=0;i<n;i++) mp[res[i]]=1;
for(auto x:mp) mp[x.first]=fl++;
for(int i=0;i<n;i++) res[i]=mp[res[i]];
return res;
}
int find_next_station(int s,int t,vector<int> c){
if(sz(c)==1) return c[0];
if(s<c[0]){
for(int i=0;i<sz(c);i++) if(s<=t && t<=c[i]) return c[i];
return c.back();
}
else{
for(int i=sz(c)-1;i>=0;i--) if(c[i]<=t && t<=s) return c[i];
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
306 ms |
948 KB |
Output is correct |
2 |
Correct |
275 ms |
952 KB |
Output is correct |
3 |
Correct |
497 ms |
684 KB |
Output is correct |
4 |
Correct |
376 ms |
684 KB |
Output is correct |
5 |
Correct |
329 ms |
684 KB |
Output is correct |
6 |
Correct |
262 ms |
940 KB |
Output is correct |
7 |
Correct |
274 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
268 ms |
920 KB |
Output is correct |
2 |
Correct |
317 ms |
824 KB |
Output is correct |
3 |
Correct |
529 ms |
684 KB |
Output is correct |
4 |
Correct |
371 ms |
684 KB |
Output is correct |
5 |
Correct |
367 ms |
684 KB |
Output is correct |
6 |
Correct |
287 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
348 ms |
956 KB |
Output is correct |
2 |
Correct |
297 ms |
952 KB |
Output is correct |
3 |
Correct |
581 ms |
684 KB |
Output is correct |
4 |
Correct |
438 ms |
684 KB |
Output is correct |
5 |
Correct |
394 ms |
684 KB |
Output is correct |
6 |
Correct |
345 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 |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Correct |
404 ms |
684 KB |
Output is correct |
12 |
Correct |
336 ms |
1072 KB |
Output is correct |
13 |
Correct |
289 ms |
1468 KB |
Output is correct |
14 |
Correct |
297 ms |
936 KB |
Output is correct |
15 |
Correct |
31 ms |
768 KB |
Output is correct |
16 |
Correct |
43 ms |
876 KB |
Output is correct |
17 |
Correct |
67 ms |
1168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
513 ms |
684 KB |
Output is correct |
2 |
Correct |
446 ms |
684 KB |
Output is correct |
3 |
Correct |
342 ms |
936 KB |
Output is correct |
4 |
Correct |
2 ms |
804 KB |
Output is correct |
5 |
Correct |
2 ms |
764 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
404 ms |
684 KB |
Output is correct |
8 |
Correct |
586 ms |
684 KB |
Output is correct |
9 |
Correct |
438 ms |
684 KB |
Output is correct |
10 |
Correct |
362 ms |
684 KB |
Output is correct |
11 |
Correct |
3 ms |
768 KB |
Output is correct |
12 |
Correct |
3 ms |
764 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
764 KB |
Output is correct |
15 |
Correct |
1 ms |
768 KB |
Output is correct |
16 |
Correct |
324 ms |
684 KB |
Output is correct |
17 |
Correct |
305 ms |
684 KB |
Output is correct |
18 |
Correct |
374 ms |
684 KB |
Output is correct |
19 |
Correct |
340 ms |
684 KB |
Output is correct |
20 |
Correct |
317 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
337 ms |
948 KB |
Output is correct |
2 |
Correct |
308 ms |
948 KB |
Output is correct |
3 |
Correct |
612 ms |
684 KB |
Output is correct |
4 |
Correct |
410 ms |
684 KB |
Output is correct |
5 |
Correct |
389 ms |
684 KB |
Output is correct |
6 |
Correct |
274 ms |
956 KB |
Output is correct |
7 |
Correct |
286 ms |
684 KB |
Output is correct |
8 |
Correct |
1 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 |
277 ms |
912 KB |
Output is correct |
12 |
Correct |
307 ms |
876 KB |
Output is correct |
13 |
Correct |
562 ms |
684 KB |
Output is correct |
14 |
Correct |
496 ms |
684 KB |
Output is correct |
15 |
Correct |
424 ms |
684 KB |
Output is correct |
16 |
Correct |
278 ms |
692 KB |
Output is correct |
17 |
Correct |
409 ms |
684 KB |
Output is correct |
18 |
Correct |
320 ms |
1060 KB |
Output is correct |
19 |
Correct |
319 ms |
1460 KB |
Output is correct |
20 |
Correct |
289 ms |
684 KB |
Output is correct |
21 |
Correct |
38 ms |
768 KB |
Output is correct |
22 |
Correct |
44 ms |
956 KB |
Output is correct |
23 |
Correct |
70 ms |
920 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 |
2 ms |
768 KB |
Output is correct |
28 |
Correct |
0 ms |
768 KB |
Output is correct |
29 |
Correct |
283 ms |
940 KB |
Output is correct |
30 |
Correct |
361 ms |
684 KB |
Output is correct |
31 |
Correct |
351 ms |
684 KB |
Output is correct |
32 |
Correct |
306 ms |
684 KB |
Output is correct |
33 |
Correct |
318 ms |
684 KB |
Output is correct |
34 |
Correct |
211 ms |
932 KB |
Output is correct |
35 |
Correct |
333 ms |
1092 KB |
Output is correct |
36 |
Correct |
305 ms |
1456 KB |
Output is correct |
37 |
Correct |
313 ms |
1052 KB |
Output is correct |
38 |
Correct |
317 ms |
1192 KB |
Output is correct |
39 |
Correct |
301 ms |
1312 KB |
Output is correct |
40 |
Correct |
301 ms |
1200 KB |
Output is correct |
41 |
Correct |
308 ms |
1308 KB |
Output is correct |
42 |
Correct |
39 ms |
892 KB |
Output is correct |
43 |
Correct |
65 ms |
1264 KB |
Output is correct |
44 |
Correct |
95 ms |
1020 KB |
Output is correct |
45 |
Correct |
90 ms |
996 KB |
Output is correct |
46 |
Correct |
172 ms |
892 KB |
Output is correct |
47 |
Correct |
165 ms |
928 KB |
Output is correct |
48 |
Correct |
34 ms |
1284 KB |
Output is correct |
49 |
Correct |
39 ms |
1652 KB |
Output is correct |