#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>graf[1010];
int pre[1010], it=-1, post[1010];
int dep[1010];
void dfs(int x, int o){
dep[x] = dep[o]+1;
pre[x] = ++it;
for(auto j: graf[x])
if(j!=o)
dfs(j, x);
post[x] = ++it;
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
int i;
dep[0] = 0;
for(i=0;i<n;i++)graf[i].clear();
for(i=0;i<n-1;i++){
graf[u[i]].push_back(v[i]);
graf[v[i]].push_back(u[i]);
}
it= -1;
dfs(0, 0);
std::vector<int> labels(n);
for (int i = 0; i < n; i++) {
if(dep[i]%2==1)
labels[i] = pre[i];
else labels[i] = post[i];
}
// for(i=0;i<n;i++)printf("%d: %d %d %d %d\n", i, dep[i], pre[i], post[i], labels[i]);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.size()==1)return c[0];
int maxi=0;
for(auto j: c)
maxi = max(maxi, j);
if(s>=maxi){
// printf(" %d\n", s);
sort(c.begin(), c.end());
if(t>s)return c[0];
if(t<c[1])return c[0];
for(int i=1;i<(int)c.size();i++)
if(i==(int)c.size()-1 || c[i+1]>t)return c[i];
}
sort(c.begin(), c.end());
if(t<s){
return c.back();
}
if(s==0){
int pom = *lower_bound(c.begin(), c.end(), t);
return pom;
}
if(t>c[(int)c.size()-1])return c.back();
int pom = *lower_bound(c.begin(), c.end(), t);
return pom;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
344 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
341 ms |
684 KB |
Output is correct |
2 |
Correct |
316 ms |
912 KB |
Output is correct |
3 |
Correct |
514 ms |
800 KB |
Output is correct |
4 |
Correct |
431 ms |
684 KB |
Output is correct |
5 |
Correct |
394 ms |
684 KB |
Output is correct |
6 |
Correct |
292 ms |
684 KB |
Output is correct |
7 |
Correct |
306 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 |
776 KB |
Output is correct |
11 |
Correct |
395 ms |
684 KB |
Output is correct |
12 |
Correct |
332 ms |
792 KB |
Output is correct |
13 |
Correct |
307 ms |
684 KB |
Output is correct |
14 |
Correct |
289 ms |
684 KB |
Output is correct |
15 |
Correct |
30 ms |
768 KB |
Output is correct |
16 |
Correct |
35 ms |
768 KB |
Output is correct |
17 |
Correct |
69 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
587 ms |
684 KB |
Output is correct |
2 |
Correct |
447 ms |
684 KB |
Output is correct |
3 |
Correct |
413 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
776 KB |
Output is correct |
5 |
Correct |
2 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
776 KB |
Output is correct |
7 |
Correct |
363 ms |
684 KB |
Output is correct |
8 |
Correct |
577 ms |
684 KB |
Output is correct |
9 |
Correct |
440 ms |
688 KB |
Output is correct |
10 |
Correct |
424 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
776 KB |
Output is correct |
12 |
Correct |
2 ms |
768 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 |
776 KB |
Output is correct |
16 |
Correct |
344 ms |
684 KB |
Output is correct |
17 |
Correct |
369 ms |
684 KB |
Output is correct |
18 |
Correct |
360 ms |
684 KB |
Output is correct |
19 |
Correct |
341 ms |
688 KB |
Output is correct |
20 |
Correct |
344 ms |
684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
357 ms |
684 KB |
Partially correct |
2 |
Partially correct |
309 ms |
908 KB |
Partially correct |
3 |
Correct |
628 ms |
684 KB |
Output is correct |
4 |
Correct |
527 ms |
684 KB |
Output is correct |
5 |
Correct |
401 ms |
684 KB |
Output is correct |
6 |
Partially correct |
303 ms |
684 KB |
Partially correct |
7 |
Partially correct |
311 ms |
684 KB |
Partially correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
772 KB |
Output is correct |
10 |
Correct |
0 ms |
772 KB |
Output is correct |
11 |
Partially correct |
317 ms |
804 KB |
Partially correct |
12 |
Partially correct |
396 ms |
688 KB |
Partially correct |
13 |
Correct |
624 ms |
684 KB |
Output is correct |
14 |
Correct |
434 ms |
684 KB |
Output is correct |
15 |
Correct |
440 ms |
936 KB |
Output is correct |
16 |
Partially correct |
320 ms |
940 KB |
Partially correct |
17 |
Correct |
375 ms |
688 KB |
Output is correct |
18 |
Partially correct |
329 ms |
796 KB |
Partially correct |
19 |
Partially correct |
322 ms |
788 KB |
Partially correct |
20 |
Partially correct |
295 ms |
684 KB |
Partially correct |
21 |
Correct |
33 ms |
768 KB |
Output is correct |
22 |
Partially correct |
46 ms |
744 KB |
Partially correct |
23 |
Partially correct |
79 ms |
720 KB |
Partially correct |
24 |
Correct |
3 ms |
768 KB |
Output is correct |
25 |
Correct |
3 ms |
776 KB |
Output is correct |
26 |
Correct |
2 ms |
776 KB |
Output is correct |
27 |
Correct |
1 ms |
768 KB |
Output is correct |
28 |
Correct |
0 ms |
776 KB |
Output is correct |
29 |
Correct |
335 ms |
684 KB |
Output is correct |
30 |
Correct |
356 ms |
684 KB |
Output is correct |
31 |
Correct |
327 ms |
684 KB |
Output is correct |
32 |
Correct |
331 ms |
684 KB |
Output is correct |
33 |
Correct |
333 ms |
684 KB |
Output is correct |
34 |
Partially correct |
229 ms |
684 KB |
Partially correct |
35 |
Partially correct |
269 ms |
940 KB |
Partially correct |
36 |
Partially correct |
312 ms |
688 KB |
Partially correct |
37 |
Partially correct |
285 ms |
684 KB |
Partially correct |
38 |
Partially correct |
309 ms |
1012 KB |
Partially correct |
39 |
Partially correct |
290 ms |
792 KB |
Partially correct |
40 |
Partially correct |
311 ms |
800 KB |
Partially correct |
41 |
Partially correct |
315 ms |
792 KB |
Partially correct |
42 |
Partially correct |
30 ms |
768 KB |
Partially correct |
43 |
Partially correct |
88 ms |
684 KB |
Partially correct |
44 |
Partially correct |
82 ms |
768 KB |
Partially correct |
45 |
Partially correct |
102 ms |
684 KB |
Partially correct |
46 |
Partially correct |
204 ms |
684 KB |
Partially correct |
47 |
Partially correct |
203 ms |
684 KB |
Partially correct |
48 |
Partially correct |
44 ms |
768 KB |
Partially correct |
49 |
Partially correct |
28 ms |
996 KB |
Partially correct |