#include<bits/stdc++.h>
using namespace std;
#include"stations.h"
#define N 100005
int st[N],en[N],cnt[N],sz;
vector<int> g[N];
void dfs(int s,int f,int c){
st[s]=sz++;
cnt[s]=c;
for(auto x:g[s]){
if(x==f)continue;
dfs(x,s,c+1);
}
en[s]=sz++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
int i,a,b,c=0;
vector<int> vec;
for(i=0;i<n;i++)g[i].clear(),sz=0;
for(i=0;i<n-1;i++){
a=u[i],b=v[i];
g[a].push_back(b);
g[b].push_back(a);
}
dfs(0,-1,1);
map<int,int> mp;
for(i=0;i<n;i++)mp[cnt[i]%2?st[i]:en[i]];
for(auto &[x,y]:mp)y=c++;
for(i=0;i<n;i++)vec.push_back(mp[cnt[i]%2?st[i]:en[i]]);
return vec;
}
int find_next_station(int s, int t,vector<int> c){
if(c[0]>s){
//s->st
if(t<s)return c.back();
for(auto x:c)if(t<=x)return x;
return c.back();
}
else{
//s->en
if(t>s)return c[0];
for(int i=c.size()-1;i>=0;i--)if(t>=c[i])return c[i];
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
483 ms |
5408 KB |
Output is correct |
2 |
Correct |
391 ms |
5448 KB |
Output is correct |
3 |
Correct |
787 ms |
5280 KB |
Output is correct |
4 |
Correct |
598 ms |
5280 KB |
Output is correct |
5 |
Correct |
474 ms |
5300 KB |
Output is correct |
6 |
Correct |
386 ms |
5412 KB |
Output is correct |
7 |
Correct |
456 ms |
5408 KB |
Output is correct |
8 |
Correct |
4 ms |
5372 KB |
Output is correct |
9 |
Correct |
6 ms |
5364 KB |
Output is correct |
10 |
Correct |
3 ms |
5372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
434 ms |
5280 KB |
Output is correct |
2 |
Correct |
468 ms |
5408 KB |
Output is correct |
3 |
Correct |
788 ms |
5296 KB |
Output is correct |
4 |
Correct |
576 ms |
5280 KB |
Output is correct |
5 |
Correct |
525 ms |
5284 KB |
Output is correct |
6 |
Correct |
396 ms |
5292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
450 ms |
5408 KB |
Output is correct |
2 |
Correct |
449 ms |
5408 KB |
Output is correct |
3 |
Correct |
814 ms |
5284 KB |
Output is correct |
4 |
Correct |
611 ms |
5284 KB |
Output is correct |
5 |
Correct |
524 ms |
5280 KB |
Output is correct |
6 |
Correct |
395 ms |
5408 KB |
Output is correct |
7 |
Correct |
405 ms |
5408 KB |
Output is correct |
8 |
Correct |
5 ms |
5368 KB |
Output is correct |
9 |
Correct |
6 ms |
5364 KB |
Output is correct |
10 |
Correct |
4 ms |
5364 KB |
Output is correct |
11 |
Correct |
573 ms |
5284 KB |
Output is correct |
12 |
Correct |
425 ms |
5528 KB |
Output is correct |
13 |
Correct |
405 ms |
5464 KB |
Output is correct |
14 |
Correct |
420 ms |
5412 KB |
Output is correct |
15 |
Correct |
49 ms |
5344 KB |
Output is correct |
16 |
Correct |
67 ms |
5296 KB |
Output is correct |
17 |
Correct |
108 ms |
5412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
782 ms |
5452 KB |
Output is correct |
2 |
Correct |
630 ms |
5280 KB |
Output is correct |
3 |
Correct |
572 ms |
5280 KB |
Output is correct |
4 |
Correct |
6 ms |
5364 KB |
Output is correct |
5 |
Correct |
6 ms |
5364 KB |
Output is correct |
6 |
Correct |
4 ms |
5364 KB |
Output is correct |
7 |
Correct |
526 ms |
5408 KB |
Output is correct |
8 |
Correct |
799 ms |
5280 KB |
Output is correct |
9 |
Correct |
609 ms |
5284 KB |
Output is correct |
10 |
Correct |
437 ms |
5288 KB |
Output is correct |
11 |
Correct |
6 ms |
5452 KB |
Output is correct |
12 |
Correct |
6 ms |
5364 KB |
Output is correct |
13 |
Correct |
6 ms |
5364 KB |
Output is correct |
14 |
Correct |
5 ms |
5364 KB |
Output is correct |
15 |
Correct |
4 ms |
5340 KB |
Output is correct |
16 |
Correct |
450 ms |
5284 KB |
Output is correct |
17 |
Correct |
406 ms |
5284 KB |
Output is correct |
18 |
Correct |
434 ms |
5292 KB |
Output is correct |
19 |
Correct |
481 ms |
5296 KB |
Output is correct |
20 |
Correct |
395 ms |
5292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
478 ms |
5412 KB |
Output is correct |
2 |
Correct |
385 ms |
5400 KB |
Output is correct |
3 |
Correct |
795 ms |
5288 KB |
Output is correct |
4 |
Correct |
627 ms |
5292 KB |
Output is correct |
5 |
Correct |
511 ms |
5288 KB |
Output is correct |
6 |
Correct |
429 ms |
5404 KB |
Output is correct |
7 |
Correct |
417 ms |
5416 KB |
Output is correct |
8 |
Correct |
4 ms |
5364 KB |
Output is correct |
9 |
Correct |
6 ms |
5372 KB |
Output is correct |
10 |
Correct |
2 ms |
5344 KB |
Output is correct |
11 |
Correct |
412 ms |
5396 KB |
Output is correct |
12 |
Correct |
442 ms |
5408 KB |
Output is correct |
13 |
Correct |
789 ms |
5284 KB |
Output is correct |
14 |
Correct |
615 ms |
5288 KB |
Output is correct |
15 |
Correct |
511 ms |
5280 KB |
Output is correct |
16 |
Correct |
448 ms |
5284 KB |
Output is correct |
17 |
Correct |
523 ms |
5288 KB |
Output is correct |
18 |
Correct |
385 ms |
5520 KB |
Output is correct |
19 |
Correct |
403 ms |
5412 KB |
Output is correct |
20 |
Correct |
391 ms |
5424 KB |
Output is correct |
21 |
Correct |
53 ms |
5364 KB |
Output is correct |
22 |
Correct |
54 ms |
5308 KB |
Output is correct |
23 |
Correct |
106 ms |
5436 KB |
Output is correct |
24 |
Correct |
6 ms |
5368 KB |
Output is correct |
25 |
Correct |
7 ms |
5372 KB |
Output is correct |
26 |
Correct |
6 ms |
5368 KB |
Output is correct |
27 |
Correct |
5 ms |
5364 KB |
Output is correct |
28 |
Correct |
3 ms |
5368 KB |
Output is correct |
29 |
Correct |
463 ms |
5292 KB |
Output is correct |
30 |
Correct |
451 ms |
5328 KB |
Output is correct |
31 |
Correct |
475 ms |
5288 KB |
Output is correct |
32 |
Correct |
438 ms |
5280 KB |
Output is correct |
33 |
Correct |
527 ms |
5292 KB |
Output is correct |
34 |
Correct |
298 ms |
5408 KB |
Output is correct |
35 |
Correct |
436 ms |
5412 KB |
Output is correct |
36 |
Correct |
415 ms |
5408 KB |
Output is correct |
37 |
Correct |
375 ms |
5412 KB |
Output is correct |
38 |
Correct |
409 ms |
5420 KB |
Output is correct |
39 |
Correct |
399 ms |
5528 KB |
Output is correct |
40 |
Correct |
429 ms |
5416 KB |
Output is correct |
41 |
Correct |
397 ms |
5408 KB |
Output is correct |
42 |
Correct |
53 ms |
5288 KB |
Output is correct |
43 |
Correct |
132 ms |
5416 KB |
Output is correct |
44 |
Correct |
127 ms |
5440 KB |
Output is correct |
45 |
Correct |
162 ms |
5448 KB |
Output is correct |
46 |
Correct |
325 ms |
5280 KB |
Output is correct |
47 |
Correct |
293 ms |
5428 KB |
Output is correct |
48 |
Correct |
76 ms |
5428 KB |
Output is correct |
49 |
Correct |
66 ms |
5444 KB |
Output is correct |