#include <bits/stdc++.h>
#define MAX 1001
#define pb push_back
#include "stations.h"
#include <vector>
using namespace std;
int col[MAX],in[MAX],out[MAX],cnt=-1;
vector<vector<int>> g;
void dfs(int v,int prev){
cnt+=col[v]%2;
in[v]=cnt;
for(auto x:g[v]){
if(x==prev){
continue;
}
col[x]=1-col[v];
dfs(x,v);
}
cnt+=1-col[v]%2;
out[v]=cnt;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
cnt=-1;
g.clear();
g.resize(n);
for(int i=0;i<n-1;i++){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
vector<int> labels(n);
col[0]=1;
dfs(0,-1);
for(int i=0;i<n;i++){
if(col[i]){
labels[i]=in[i];
}
else{
labels[i]=out[i];
}
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
int tp=0;
int sz=(int)c.size();
for(auto x:c){
if(x>s){
tp=1;
}
}
if(tp==0){
for(int i=sz-1;i>0;i--){
int num=s-1;
if(i!=sz-1){
num=c[i+1]-1;
}
if(t>=c[i] && t<=num){
return c[i];
}
}
return c[0];
}
else{
for(int i=0;i<sz-1;i++){
int num=s;
if(i){
num=c[i-1];
}
if(t>=num && t<=c[i]){
return c[i];
}
}
return c[sz-1];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
312 ms |
684 KB |
Output is correct |
2 |
Correct |
230 ms |
940 KB |
Output is correct |
3 |
Correct |
503 ms |
684 KB |
Output is correct |
4 |
Correct |
381 ms |
688 KB |
Output is correct |
5 |
Correct |
314 ms |
688 KB |
Output is correct |
6 |
Correct |
241 ms |
684 KB |
Output is correct |
7 |
Correct |
250 ms |
684 KB |
Output is correct |
8 |
Correct |
0 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
684 KB |
Output is correct |
2 |
Correct |
272 ms |
684 KB |
Output is correct |
3 |
Correct |
505 ms |
684 KB |
Output is correct |
4 |
Correct |
371 ms |
684 KB |
Output is correct |
5 |
Correct |
337 ms |
684 KB |
Output is correct |
6 |
Correct |
226 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
239 ms |
940 KB |
Output is correct |
2 |
Correct |
268 ms |
940 KB |
Output is correct |
3 |
Correct |
537 ms |
684 KB |
Output is correct |
4 |
Correct |
369 ms |
684 KB |
Output is correct |
5 |
Correct |
326 ms |
684 KB |
Output is correct |
6 |
Correct |
255 ms |
684 KB |
Output is correct |
7 |
Correct |
246 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
334 ms |
684 KB |
Output is correct |
12 |
Correct |
254 ms |
936 KB |
Output is correct |
13 |
Correct |
255 ms |
932 KB |
Output is correct |
14 |
Correct |
236 ms |
684 KB |
Output is correct |
15 |
Correct |
21 ms |
764 KB |
Output is correct |
16 |
Correct |
31 ms |
764 KB |
Output is correct |
17 |
Correct |
48 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
497 ms |
684 KB |
Output is correct |
2 |
Correct |
368 ms |
684 KB |
Output is correct |
3 |
Correct |
327 ms |
684 KB |
Output is correct |
4 |
Correct |
0 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
776 KB |
Output is correct |
6 |
Correct |
0 ms |
768 KB |
Output is correct |
7 |
Correct |
325 ms |
684 KB |
Output is correct |
8 |
Correct |
504 ms |
684 KB |
Output is correct |
9 |
Correct |
374 ms |
684 KB |
Output is correct |
10 |
Correct |
317 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
1016 KB |
Output is correct |
12 |
Correct |
2 ms |
776 KB |
Output is correct |
13 |
Correct |
1 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 |
281 ms |
688 KB |
Output is correct |
17 |
Correct |
271 ms |
684 KB |
Output is correct |
18 |
Correct |
283 ms |
684 KB |
Output is correct |
19 |
Correct |
282 ms |
684 KB |
Output is correct |
20 |
Correct |
323 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
284 ms |
940 KB |
Output is correct |
2 |
Correct |
254 ms |
940 KB |
Output is correct |
3 |
Correct |
526 ms |
688 KB |
Output is correct |
4 |
Correct |
379 ms |
684 KB |
Output is correct |
5 |
Correct |
338 ms |
684 KB |
Output is correct |
6 |
Correct |
249 ms |
684 KB |
Output is correct |
7 |
Correct |
231 ms |
680 KB |
Output is correct |
8 |
Correct |
0 ms |
776 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
776 KB |
Output is correct |
11 |
Correct |
266 ms |
688 KB |
Output is correct |
12 |
Correct |
320 ms |
684 KB |
Output is correct |
13 |
Correct |
485 ms |
684 KB |
Output is correct |
14 |
Correct |
390 ms |
684 KB |
Output is correct |
15 |
Correct |
351 ms |
684 KB |
Output is correct |
16 |
Correct |
267 ms |
684 KB |
Output is correct |
17 |
Correct |
335 ms |
684 KB |
Output is correct |
18 |
Correct |
222 ms |
772 KB |
Output is correct |
19 |
Correct |
263 ms |
1020 KB |
Output is correct |
20 |
Correct |
231 ms |
684 KB |
Output is correct |
21 |
Correct |
26 ms |
768 KB |
Output is correct |
22 |
Correct |
29 ms |
768 KB |
Output is correct |
23 |
Correct |
54 ms |
768 KB |
Output is correct |
24 |
Correct |
2 ms |
764 KB |
Output is correct |
25 |
Correct |
2 ms |
780 KB |
Output is correct |
26 |
Correct |
1 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
764 KB |
Output is correct |
28 |
Correct |
0 ms |
768 KB |
Output is correct |
29 |
Correct |
280 ms |
684 KB |
Output is correct |
30 |
Correct |
288 ms |
684 KB |
Output is correct |
31 |
Correct |
299 ms |
680 KB |
Output is correct |
32 |
Correct |
305 ms |
684 KB |
Output is correct |
33 |
Correct |
307 ms |
684 KB |
Output is correct |
34 |
Correct |
181 ms |
940 KB |
Output is correct |
35 |
Correct |
235 ms |
684 KB |
Output is correct |
36 |
Correct |
241 ms |
940 KB |
Output is correct |
37 |
Correct |
237 ms |
764 KB |
Output is correct |
38 |
Correct |
223 ms |
768 KB |
Output is correct |
39 |
Correct |
254 ms |
768 KB |
Output is correct |
40 |
Correct |
248 ms |
1020 KB |
Output is correct |
41 |
Correct |
239 ms |
1188 KB |
Output is correct |
42 |
Correct |
40 ms |
768 KB |
Output is correct |
43 |
Correct |
58 ms |
768 KB |
Output is correct |
44 |
Correct |
73 ms |
760 KB |
Output is correct |
45 |
Correct |
69 ms |
764 KB |
Output is correct |
46 |
Correct |
153 ms |
684 KB |
Output is correct |
47 |
Correct |
175 ms |
716 KB |
Output is correct |
48 |
Correct |
23 ms |
764 KB |
Output is correct |
49 |
Correct |
24 ms |
768 KB |
Output is correct |