#include <bits/stdc++.h>
using namespace std;
#include "stations.h"
#define fin(i,s,n) for(auto i = s; i < n; ++i)
#define fine(i,s,n) for(auto i = s; i <= n; ++i)
#define x first
#define y second
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
template<class T> ostream& operator<<(ostream& os, vector<T> v) {
if(v.empty()) return os << "[]";
os << '[' << v[0];
fin(i,1,int(v.size())) os << ',' << v[i];
return os << ']';
}
template<class A, class B> ostream& operator<<(ostream& os, pair<A,B> p) {
return os << '(' << p.x << ',' << p.y << ')';
}
const int maxn = 1005;
vi l;
vi g[maxn];
int T;
void dfs(int u, int p = -1) {
int iu = T++;
for(int v : g[u]) if(v!=p) dfs(v,u);
int ou = T-1;
l[u] = 1000*iu+ou;
}
vi label(int n, int k, vi u, vi v) {
l = vi(n,-1),T = 0;
fin(i,0,n) g[i].clear();
fin(i,0,n-1) g[u[i]].pb(v[i]),g[v[i]].pb(u[i]);
dfs(0);
return l;
}
int dir(int a, int b){
if(a==b) return 0;
return b>a?1:-1;
}
ii dcmp(int x) {
return {x/1000,x%1000};
}
bool anc(int u, int v) {
// while(v>=u) {
// if(u==v) return 1;
// v = (v-1)/2;
// }
// return 0;
ii tu = dcmp(u), tv = dcmp(v);
return tu.x <= tv.x && tu.y >= tv.y;
}
int find_next_station(int s, int t, vi c) {
if(anc(s,t)) {
vi ops;
for(int v : c) if(anc(v,t)) ops.pb(v);
if(ops.empty()) return c[0];
return *max_element(all(ops));
}
for(int v : c) if(anc(v,s)) return v;
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
308 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
300 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
705 ms |
636 KB |
Output is correct |
2 |
Correct |
707 ms |
528 KB |
Output is correct |
3 |
Correct |
915 ms |
492 KB |
Output is correct |
4 |
Correct |
827 ms |
512 KB |
Output is correct |
5 |
Correct |
988 ms |
512 KB |
Output is correct |
6 |
Correct |
714 ms |
516 KB |
Output is correct |
7 |
Correct |
528 ms |
528 KB |
Output is correct |
8 |
Correct |
4 ms |
468 KB |
Output is correct |
9 |
Correct |
6 ms |
468 KB |
Output is correct |
10 |
Correct |
0 ms |
476 KB |
Output is correct |
11 |
Correct |
619 ms |
400 KB |
Output is correct |
12 |
Correct |
511 ms |
624 KB |
Output is correct |
13 |
Correct |
479 ms |
612 KB |
Output is correct |
14 |
Correct |
532 ms |
504 KB |
Output is correct |
15 |
Correct |
90 ms |
528 KB |
Output is correct |
16 |
Correct |
101 ms |
564 KB |
Output is correct |
17 |
Correct |
181 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1190 ms |
400 KB |
Output is correct |
2 |
Correct |
848 ms |
400 KB |
Output is correct |
3 |
Correct |
995 ms |
508 KB |
Output is correct |
4 |
Correct |
3 ms |
472 KB |
Output is correct |
5 |
Correct |
5 ms |
464 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
725 ms |
400 KB |
Output is correct |
8 |
Correct |
1071 ms |
400 KB |
Output is correct |
9 |
Correct |
814 ms |
516 KB |
Output is correct |
10 |
Correct |
594 ms |
400 KB |
Output is correct |
11 |
Correct |
8 ms |
468 KB |
Output is correct |
12 |
Correct |
6 ms |
468 KB |
Output is correct |
13 |
Correct |
4 ms |
468 KB |
Output is correct |
14 |
Correct |
5 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
752 ms |
400 KB |
Output is correct |
17 |
Correct |
645 ms |
400 KB |
Output is correct |
18 |
Correct |
549 ms |
508 KB |
Output is correct |
19 |
Correct |
755 ms |
400 KB |
Output is correct |
20 |
Correct |
493 ms |
476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
673 ms |
516 KB |
Partially correct |
2 |
Partially correct |
525 ms |
528 KB |
Partially correct |
3 |
Partially correct |
1105 ms |
400 KB |
Partially correct |
4 |
Partially correct |
760 ms |
508 KB |
Partially correct |
5 |
Partially correct |
784 ms |
512 KB |
Partially correct |
6 |
Partially correct |
508 ms |
492 KB |
Partially correct |
7 |
Partially correct |
456 ms |
508 KB |
Partially correct |
8 |
Partially correct |
3 ms |
472 KB |
Partially correct |
9 |
Partially correct |
5 ms |
468 KB |
Partially correct |
10 |
Partially correct |
2 ms |
468 KB |
Partially correct |
11 |
Partially correct |
535 ms |
528 KB |
Partially correct |
12 |
Partially correct |
730 ms |
632 KB |
Partially correct |
13 |
Partially correct |
881 ms |
400 KB |
Partially correct |
14 |
Partially correct |
910 ms |
512 KB |
Partially correct |
15 |
Partially correct |
878 ms |
548 KB |
Partially correct |
16 |
Partially correct |
556 ms |
500 KB |
Partially correct |
17 |
Partially correct |
674 ms |
400 KB |
Partially correct |
18 |
Partially correct |
506 ms |
596 KB |
Partially correct |
19 |
Partially correct |
476 ms |
628 KB |
Partially correct |
20 |
Partially correct |
486 ms |
512 KB |
Partially correct |
21 |
Partially correct |
59 ms |
428 KB |
Partially correct |
22 |
Partially correct |
80 ms |
656 KB |
Partially correct |
23 |
Partially correct |
98 ms |
528 KB |
Partially correct |
24 |
Partially correct |
6 ms |
468 KB |
Partially correct |
25 |
Partially correct |
5 ms |
468 KB |
Partially correct |
26 |
Partially correct |
6 ms |
468 KB |
Partially correct |
27 |
Partially correct |
6 ms |
452 KB |
Partially correct |
28 |
Partially correct |
2 ms |
468 KB |
Partially correct |
29 |
Partially correct |
634 ms |
400 KB |
Partially correct |
30 |
Partially correct |
680 ms |
400 KB |
Partially correct |
31 |
Partially correct |
797 ms |
400 KB |
Partially correct |
32 |
Partially correct |
612 ms |
400 KB |
Partially correct |
33 |
Partially correct |
646 ms |
512 KB |
Partially correct |
34 |
Partially correct |
393 ms |
612 KB |
Partially correct |
35 |
Partially correct |
414 ms |
684 KB |
Partially correct |
36 |
Partially correct |
531 ms |
604 KB |
Partially correct |
37 |
Partially correct |
489 ms |
620 KB |
Partially correct |
38 |
Partially correct |
601 ms |
692 KB |
Partially correct |
39 |
Partially correct |
502 ms |
616 KB |
Partially correct |
40 |
Partially correct |
558 ms |
628 KB |
Partially correct |
41 |
Partially correct |
645 ms |
800 KB |
Partially correct |
42 |
Partially correct |
71 ms |
528 KB |
Partially correct |
43 |
Partially correct |
132 ms |
644 KB |
Partially correct |
44 |
Partially correct |
190 ms |
528 KB |
Partially correct |
45 |
Partially correct |
217 ms |
640 KB |
Partially correct |
46 |
Partially correct |
535 ms |
512 KB |
Partially correct |
47 |
Partially correct |
406 ms |
512 KB |
Partially correct |
48 |
Partially correct |
100 ms |
752 KB |
Partially correct |
49 |
Partially correct |
92 ms |
724 KB |
Partially correct |