# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166768 | 2019-12-04T03:26:38 Z | abil | Birthday gift (IZhO18_treearray) | C++14 | 4000 ms | 37760 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (2e5 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); vector<int > g[N]; int up[20][N], tin[N], tout[N], timer, a[N]; void dfs(int v,int pr){ tin[v] = ++timer; up[0][v] = pr; for(int i = 1;i <= 19; i++){ up[i][v] = up[i - 1][up[i - 1][v]]; } for(auto to : g[v]){ if(to != pr){ dfs(to, v); } } tout[v] = ++timer; } bool upper(int a,int b){ return tin[a] <= tin[b] && tout[a] >= tout[b]; } int lca(int a,int b){ if(upper(a, b)){ return a; } if(upper(b, a)){ return b; } for(int i = 19;i >= 0; i--){ if(!upper(up[i][a], b)){ a = up[i][a]; } } a = up[0][a]; return a; } main() { int n, m, q, v, u; cin >> n >> m >> q; for(int i = 1;i <= n - 1; i++){ scanf("%d%d", &v, &u); g[u].pb(v); g[v].pb(u); } for(int i = 1;i <= m; i++){ scanf("%d", &a[i]); } dfs(1, 1); int type, l, r, x; while(q--){ scanf("%d", &type); if(type == 1){ scanf("%d%d", &x, &v); a[x] = v; } else{ scanf("%d%d%d",&l, &r, &v); int xl = -1, xr = -1; for(int i = l;i <= r; i++){ if(a[i] == v){ xr = xl = i; break; } if(i < r && lca(a[i],a[i + 1]) == v){ xl = i; xr = i + 1; break; } } printf("%d %d\n", xl, xr); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | n=5 |
2 | Correct | 7 ms | 5112 KB | n=100 |
3 | Correct | 6 ms | 5112 KB | n=100 |
4 | Correct | 6 ms | 5112 KB | n=100 |
5 | Correct | 6 ms | 5112 KB | n=100 |
6 | Correct | 7 ms | 5112 KB | n=100 |
7 | Correct | 6 ms | 5112 KB | n=100 |
8 | Correct | 7 ms | 5112 KB | n=100 |
9 | Correct | 6 ms | 5112 KB | n=100 |
10 | Correct | 6 ms | 5112 KB | n=100 |
11 | Correct | 8 ms | 5112 KB | n=100 |
12 | Correct | 6 ms | 5112 KB | n=100 |
13 | Correct | 6 ms | 5112 KB | n=100 |
14 | Correct | 6 ms | 5116 KB | n=100 |
15 | Correct | 6 ms | 5116 KB | n=100 |
16 | Correct | 6 ms | 5112 KB | n=100 |
17 | Correct | 6 ms | 5112 KB | n=100 |
18 | Correct | 7 ms | 5112 KB | n=100 |
19 | Correct | 6 ms | 5112 KB | n=100 |
20 | Correct | 7 ms | 5112 KB | n=100 |
21 | Correct | 7 ms | 5112 KB | n=100 |
22 | Correct | 7 ms | 5112 KB | n=100 |
23 | Correct | 6 ms | 5112 KB | n=100 |
24 | Correct | 6 ms | 5112 KB | n=100 |
25 | Correct | 6 ms | 5112 KB | n=100 |
26 | Correct | 6 ms | 5112 KB | n=12 |
27 | Correct | 7 ms | 5112 KB | n=100 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | n=5 |
2 | Correct | 7 ms | 5112 KB | n=100 |
3 | Correct | 6 ms | 5112 KB | n=100 |
4 | Correct | 6 ms | 5112 KB | n=100 |
5 | Correct | 6 ms | 5112 KB | n=100 |
6 | Correct | 7 ms | 5112 KB | n=100 |
7 | Correct | 6 ms | 5112 KB | n=100 |
8 | Correct | 7 ms | 5112 KB | n=100 |
9 | Correct | 6 ms | 5112 KB | n=100 |
10 | Correct | 6 ms | 5112 KB | n=100 |
11 | Correct | 8 ms | 5112 KB | n=100 |
12 | Correct | 6 ms | 5112 KB | n=100 |
13 | Correct | 6 ms | 5112 KB | n=100 |
14 | Correct | 6 ms | 5116 KB | n=100 |
15 | Correct | 6 ms | 5116 KB | n=100 |
16 | Correct | 6 ms | 5112 KB | n=100 |
17 | Correct | 6 ms | 5112 KB | n=100 |
18 | Correct | 7 ms | 5112 KB | n=100 |
19 | Correct | 6 ms | 5112 KB | n=100 |
20 | Correct | 7 ms | 5112 KB | n=100 |
21 | Correct | 7 ms | 5112 KB | n=100 |
22 | Correct | 7 ms | 5112 KB | n=100 |
23 | Correct | 6 ms | 5112 KB | n=100 |
24 | Correct | 6 ms | 5112 KB | n=100 |
25 | Correct | 6 ms | 5112 KB | n=100 |
26 | Correct | 6 ms | 5112 KB | n=12 |
27 | Correct | 7 ms | 5112 KB | n=100 |
28 | Correct | 6 ms | 5240 KB | n=500 |
29 | Correct | 7 ms | 5240 KB | n=500 |
30 | Correct | 8 ms | 5240 KB | n=500 |
31 | Correct | 8 ms | 5240 KB | n=500 |
32 | Correct | 7 ms | 5240 KB | n=500 |
33 | Correct | 8 ms | 5240 KB | n=500 |
34 | Correct | 7 ms | 5240 KB | n=500 |
35 | Correct | 7 ms | 5240 KB | n=500 |
36 | Correct | 21 ms | 5272 KB | n=500 |
37 | Correct | 22 ms | 5268 KB | n=500 |
38 | Correct | 22 ms | 5240 KB | n=500 |
39 | Correct | 15 ms | 5240 KB | n=500 |
40 | Correct | 15 ms | 5112 KB | n=500 |
41 | Correct | 15 ms | 5240 KB | n=500 |
42 | Correct | 14 ms | 5240 KB | n=500 |
43 | Correct | 13 ms | 5240 KB | n=500 |
44 | Correct | 14 ms | 5240 KB | n=500 |
45 | Correct | 7 ms | 5240 KB | n=500 |
46 | Correct | 8 ms | 5240 KB | n=500 |
47 | Correct | 8 ms | 5240 KB | n=500 |
48 | Correct | 8 ms | 5240 KB | n=500 |
49 | Correct | 7 ms | 5240 KB | n=500 |
50 | Correct | 11 ms | 5240 KB | n=500 |
51 | Correct | 8 ms | 5240 KB | n=500 |
52 | Correct | 8 ms | 5240 KB | n=500 |
53 | Correct | 9 ms | 5112 KB | n=500 |
54 | Correct | 7 ms | 5240 KB | n=500 |
55 | Correct | 6 ms | 5112 KB | n=278 |
56 | Correct | 8 ms | 5244 KB | n=500 |
57 | Correct | 8 ms | 5240 KB | n=500 |
58 | Correct | 18 ms | 5240 KB | n=500 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | n=5 |
2 | Correct | 7 ms | 5112 KB | n=100 |
3 | Correct | 6 ms | 5112 KB | n=100 |
4 | Correct | 6 ms | 5112 KB | n=100 |
5 | Correct | 6 ms | 5112 KB | n=100 |
6 | Correct | 7 ms | 5112 KB | n=100 |
7 | Correct | 6 ms | 5112 KB | n=100 |
8 | Correct | 7 ms | 5112 KB | n=100 |
9 | Correct | 6 ms | 5112 KB | n=100 |
10 | Correct | 6 ms | 5112 KB | n=100 |
11 | Correct | 8 ms | 5112 KB | n=100 |
12 | Correct | 6 ms | 5112 KB | n=100 |
13 | Correct | 6 ms | 5112 KB | n=100 |
14 | Correct | 6 ms | 5116 KB | n=100 |
15 | Correct | 6 ms | 5116 KB | n=100 |
16 | Correct | 6 ms | 5112 KB | n=100 |
17 | Correct | 6 ms | 5112 KB | n=100 |
18 | Correct | 7 ms | 5112 KB | n=100 |
19 | Correct | 6 ms | 5112 KB | n=100 |
20 | Correct | 7 ms | 5112 KB | n=100 |
21 | Correct | 7 ms | 5112 KB | n=100 |
22 | Correct | 7 ms | 5112 KB | n=100 |
23 | Correct | 6 ms | 5112 KB | n=100 |
24 | Correct | 6 ms | 5112 KB | n=100 |
25 | Correct | 6 ms | 5112 KB | n=100 |
26 | Correct | 6 ms | 5112 KB | n=12 |
27 | Correct | 7 ms | 5112 KB | n=100 |
28 | Correct | 6 ms | 5240 KB | n=500 |
29 | Correct | 7 ms | 5240 KB | n=500 |
30 | Correct | 8 ms | 5240 KB | n=500 |
31 | Correct | 8 ms | 5240 KB | n=500 |
32 | Correct | 7 ms | 5240 KB | n=500 |
33 | Correct | 8 ms | 5240 KB | n=500 |
34 | Correct | 7 ms | 5240 KB | n=500 |
35 | Correct | 7 ms | 5240 KB | n=500 |
36 | Correct | 21 ms | 5272 KB | n=500 |
37 | Correct | 22 ms | 5268 KB | n=500 |
38 | Correct | 22 ms | 5240 KB | n=500 |
39 | Correct | 15 ms | 5240 KB | n=500 |
40 | Correct | 15 ms | 5112 KB | n=500 |
41 | Correct | 15 ms | 5240 KB | n=500 |
42 | Correct | 14 ms | 5240 KB | n=500 |
43 | Correct | 13 ms | 5240 KB | n=500 |
44 | Correct | 14 ms | 5240 KB | n=500 |
45 | Correct | 7 ms | 5240 KB | n=500 |
46 | Correct | 8 ms | 5240 KB | n=500 |
47 | Correct | 8 ms | 5240 KB | n=500 |
48 | Correct | 8 ms | 5240 KB | n=500 |
49 | Correct | 7 ms | 5240 KB | n=500 |
50 | Correct | 11 ms | 5240 KB | n=500 |
51 | Correct | 8 ms | 5240 KB | n=500 |
52 | Correct | 8 ms | 5240 KB | n=500 |
53 | Correct | 9 ms | 5112 KB | n=500 |
54 | Correct | 7 ms | 5240 KB | n=500 |
55 | Correct | 6 ms | 5112 KB | n=278 |
56 | Correct | 8 ms | 5244 KB | n=500 |
57 | Correct | 8 ms | 5240 KB | n=500 |
58 | Correct | 18 ms | 5240 KB | n=500 |
59 | Correct | 10 ms | 5368 KB | n=2000 |
60 | Correct | 11 ms | 5556 KB | n=2000 |
61 | Correct | 25 ms | 5368 KB | n=2000 |
62 | Correct | 29 ms | 5368 KB | n=2000 |
63 | Correct | 10 ms | 5340 KB | n=2000 |
64 | Correct | 33 ms | 5496 KB | n=2000 |
65 | Correct | 10 ms | 5368 KB | n=2000 |
66 | Correct | 20 ms | 5496 KB | n=2000 |
67 | Correct | 11 ms | 5368 KB | n=2000 |
68 | Correct | 27 ms | 5496 KB | n=2000 |
69 | Correct | 308 ms | 5496 KB | n=2000 |
70 | Correct | 305 ms | 5496 KB | n=2000 |
71 | Correct | 328 ms | 5752 KB | n=2000 |
72 | Correct | 153 ms | 5496 KB | n=2000 |
73 | Correct | 171 ms | 5496 KB | n=2000 |
74 | Correct | 9 ms | 5496 KB | n=1844 |
75 | Correct | 158 ms | 5624 KB | n=2000 |
76 | Correct | 156 ms | 5496 KB | n=2000 |
77 | Correct | 151 ms | 5496 KB | n=2000 |
78 | Correct | 164 ms | 5624 KB | n=2000 |
79 | Correct | 11 ms | 5496 KB | n=2000 |
80 | Correct | 15 ms | 5500 KB | n=2000 |
81 | Correct | 26 ms | 5496 KB | n=2000 |
82 | Correct | 9 ms | 5500 KB | n=2000 |
83 | Correct | 20 ms | 5496 KB | n=2000 |
84 | Correct | 104 ms | 5612 KB | n=2000 |
85 | Correct | 62 ms | 5496 KB | n=2000 |
86 | Correct | 64 ms | 5500 KB | n=2000 |
87 | Correct | 101 ms | 5496 KB | n=2000 |
88 | Correct | 22 ms | 5608 KB | n=2000 |
89 | Correct | 21 ms | 5596 KB | n=2000 |
90 | Correct | 14 ms | 5496 KB | n=2000 |
91 | Correct | 235 ms | 5608 KB | n=2000 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | n=5 |
2 | Correct | 7 ms | 5112 KB | n=100 |
3 | Correct | 6 ms | 5112 KB | n=100 |
4 | Correct | 6 ms | 5112 KB | n=100 |
5 | Correct | 6 ms | 5112 KB | n=100 |
6 | Correct | 7 ms | 5112 KB | n=100 |
7 | Correct | 6 ms | 5112 KB | n=100 |
8 | Correct | 7 ms | 5112 KB | n=100 |
9 | Correct | 6 ms | 5112 KB | n=100 |
10 | Correct | 6 ms | 5112 KB | n=100 |
11 | Correct | 8 ms | 5112 KB | n=100 |
12 | Correct | 6 ms | 5112 KB | n=100 |
13 | Correct | 6 ms | 5112 KB | n=100 |
14 | Correct | 6 ms | 5116 KB | n=100 |
15 | Correct | 6 ms | 5116 KB | n=100 |
16 | Correct | 6 ms | 5112 KB | n=100 |
17 | Correct | 6 ms | 5112 KB | n=100 |
18 | Correct | 7 ms | 5112 KB | n=100 |
19 | Correct | 6 ms | 5112 KB | n=100 |
20 | Correct | 7 ms | 5112 KB | n=100 |
21 | Correct | 7 ms | 5112 KB | n=100 |
22 | Correct | 7 ms | 5112 KB | n=100 |
23 | Correct | 6 ms | 5112 KB | n=100 |
24 | Correct | 6 ms | 5112 KB | n=100 |
25 | Correct | 6 ms | 5112 KB | n=100 |
26 | Correct | 6 ms | 5112 KB | n=12 |
27 | Correct | 7 ms | 5112 KB | n=100 |
28 | Correct | 6 ms | 5240 KB | n=500 |
29 | Correct | 7 ms | 5240 KB | n=500 |
30 | Correct | 8 ms | 5240 KB | n=500 |
31 | Correct | 8 ms | 5240 KB | n=500 |
32 | Correct | 7 ms | 5240 KB | n=500 |
33 | Correct | 8 ms | 5240 KB | n=500 |
34 | Correct | 7 ms | 5240 KB | n=500 |
35 | Correct | 7 ms | 5240 KB | n=500 |
36 | Correct | 21 ms | 5272 KB | n=500 |
37 | Correct | 22 ms | 5268 KB | n=500 |
38 | Correct | 22 ms | 5240 KB | n=500 |
39 | Correct | 15 ms | 5240 KB | n=500 |
40 | Correct | 15 ms | 5112 KB | n=500 |
41 | Correct | 15 ms | 5240 KB | n=500 |
42 | Correct | 14 ms | 5240 KB | n=500 |
43 | Correct | 13 ms | 5240 KB | n=500 |
44 | Correct | 14 ms | 5240 KB | n=500 |
45 | Correct | 7 ms | 5240 KB | n=500 |
46 | Correct | 8 ms | 5240 KB | n=500 |
47 | Correct | 8 ms | 5240 KB | n=500 |
48 | Correct | 8 ms | 5240 KB | n=500 |
49 | Correct | 7 ms | 5240 KB | n=500 |
50 | Correct | 11 ms | 5240 KB | n=500 |
51 | Correct | 8 ms | 5240 KB | n=500 |
52 | Correct | 8 ms | 5240 KB | n=500 |
53 | Correct | 9 ms | 5112 KB | n=500 |
54 | Correct | 7 ms | 5240 KB | n=500 |
55 | Correct | 6 ms | 5112 KB | n=278 |
56 | Correct | 8 ms | 5244 KB | n=500 |
57 | Correct | 8 ms | 5240 KB | n=500 |
58 | Correct | 18 ms | 5240 KB | n=500 |
59 | Correct | 10 ms | 5368 KB | n=2000 |
60 | Correct | 11 ms | 5556 KB | n=2000 |
61 | Correct | 25 ms | 5368 KB | n=2000 |
62 | Correct | 29 ms | 5368 KB | n=2000 |
63 | Correct | 10 ms | 5340 KB | n=2000 |
64 | Correct | 33 ms | 5496 KB | n=2000 |
65 | Correct | 10 ms | 5368 KB | n=2000 |
66 | Correct | 20 ms | 5496 KB | n=2000 |
67 | Correct | 11 ms | 5368 KB | n=2000 |
68 | Correct | 27 ms | 5496 KB | n=2000 |
69 | Correct | 308 ms | 5496 KB | n=2000 |
70 | Correct | 305 ms | 5496 KB | n=2000 |
71 | Correct | 328 ms | 5752 KB | n=2000 |
72 | Correct | 153 ms | 5496 KB | n=2000 |
73 | Correct | 171 ms | 5496 KB | n=2000 |
74 | Correct | 9 ms | 5496 KB | n=1844 |
75 | Correct | 158 ms | 5624 KB | n=2000 |
76 | Correct | 156 ms | 5496 KB | n=2000 |
77 | Correct | 151 ms | 5496 KB | n=2000 |
78 | Correct | 164 ms | 5624 KB | n=2000 |
79 | Correct | 11 ms | 5496 KB | n=2000 |
80 | Correct | 15 ms | 5500 KB | n=2000 |
81 | Correct | 26 ms | 5496 KB | n=2000 |
82 | Correct | 9 ms | 5500 KB | n=2000 |
83 | Correct | 20 ms | 5496 KB | n=2000 |
84 | Correct | 104 ms | 5612 KB | n=2000 |
85 | Correct | 62 ms | 5496 KB | n=2000 |
86 | Correct | 64 ms | 5500 KB | n=2000 |
87 | Correct | 101 ms | 5496 KB | n=2000 |
88 | Correct | 22 ms | 5608 KB | n=2000 |
89 | Correct | 21 ms | 5596 KB | n=2000 |
90 | Correct | 14 ms | 5496 KB | n=2000 |
91 | Correct | 235 ms | 5608 KB | n=2000 |
92 | Execution timed out | 4080 ms | 37760 KB | Time limit exceeded |
93 | Halted | 0 ms | 0 KB | - |