# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
74507 | 2018-09-02T16:21:07 Z | win11905 | Birthday gift (IZhO18_treearray) | C++11 | 1702 ms | 262596 KB |
#include <bits/stdc++.h> using namespace std; const int N = 2e5+5; int n, m, q, A[N]; int par[N][18], dep[N]; vector<int> g[N]; set<int> pos[N], lca_pos[N]; void init_lca(int u, int p) { for(int i = 1; i < 18; ++i) par[u][i] = par[par[u][i-1]][i-1]; for(int v : g[u]) if(v != p) par[v][0] = u, dep[v] = dep[u] + 1, init_lca(v, u); } int get_lca(int u, int v) { if(dep[u] < dep[v]) swap(u, v); for(int i = 17; ~i; --i) if(dep[par[u][i]] >= dep[v]) u = par[u][i]; if(u == v) return u; for(int i = 17; ~i; --i) if(par[u][i] != par[v][i]) u = par[u][i], v = par[v][i]; return par[u][0]; } int main() { scanf("%d %d %d", &n, &m, &q); for(int i = 1, u, v; i < n; ++i) { scanf("%d %d", &u, &v); g[u].emplace_back(v), g[v].emplace_back(u); } for(int i = 1; i <= n; ++i) pos[i].emplace(m+1), lca_pos[i].emplace(m+1); init_lca(1, 0); for(int i = 1; i <= m; ++i) scanf("%d", A+i), pos[A[i]].emplace(i); for(int i = 1; i < m; ++i) lca_pos[get_lca(A[i], A[i+1])].emplace(i); for(int i = 0, tp, l, r, v; i < q; ++i) { scanf("%d", &tp); if(tp == 1) { scanf("%d %d", &tp, &v); pos[A[tp]].erase(tp); if(tp != 1) lca_pos[get_lca(A[tp], A[tp-1])].erase(tp-1); if(tp != m) lca_pos[get_lca(A[tp], A[tp+1])].erase(tp); A[tp] = v; pos[A[tp]].emplace(tp); if(tp != 1) lca_pos[get_lca(A[tp], A[tp-1])].emplace(tp-1); if(tp != m) lca_pos[get_lca(A[tp], A[tp+1])].emplace(tp); } else { scanf("%d %d %d", &l, &r, &v); int a1 = *pos[v].lower_bound(l), a2 = *lca_pos[v].lower_bound(l); if(a1 <= r) printf("%d %d\n", a1, a1); else if(a2 < r) printf("%d %d\n", a2, a2+1); else puts("-1 -1"); } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 23928 KB | n=5 |
2 | Correct | 22 ms | 24060 KB | n=100 |
3 | Correct | 22 ms | 24060 KB | n=100 |
4 | Correct | 21 ms | 24060 KB | n=100 |
5 | Correct | 21 ms | 24060 KB | n=100 |
6 | Correct | 21 ms | 24060 KB | n=100 |
7 | Correct | 21 ms | 24060 KB | n=100 |
8 | Correct | 22 ms | 24060 KB | n=100 |
9 | Correct | 21 ms | 24060 KB | n=100 |
10 | Correct | 23 ms | 24060 KB | n=100 |
11 | Correct | 24 ms | 24076 KB | n=100 |
12 | Correct | 21 ms | 24076 KB | n=100 |
13 | Correct | 21 ms | 24076 KB | n=100 |
14 | Correct | 22 ms | 24076 KB | n=100 |
15 | Correct | 22 ms | 24116 KB | n=100 |
16 | Correct | 25 ms | 24116 KB | n=100 |
17 | Correct | 21 ms | 24116 KB | n=100 |
18 | Correct | 22 ms | 24176 KB | n=100 |
19 | Correct | 24 ms | 24176 KB | n=100 |
20 | Correct | 22 ms | 24176 KB | n=100 |
21 | Correct | 21 ms | 24176 KB | n=100 |
22 | Correct | 21 ms | 24176 KB | n=100 |
23 | Correct | 21 ms | 24176 KB | n=100 |
24 | Correct | 21 ms | 24176 KB | n=100 |
25 | Correct | 22 ms | 24176 KB | n=100 |
26 | Correct | 22 ms | 24176 KB | n=12 |
27 | Correct | 22 ms | 24176 KB | n=100 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 23928 KB | n=5 |
2 | Correct | 22 ms | 24060 KB | n=100 |
3 | Correct | 22 ms | 24060 KB | n=100 |
4 | Correct | 21 ms | 24060 KB | n=100 |
5 | Correct | 21 ms | 24060 KB | n=100 |
6 | Correct | 21 ms | 24060 KB | n=100 |
7 | Correct | 21 ms | 24060 KB | n=100 |
8 | Correct | 22 ms | 24060 KB | n=100 |
9 | Correct | 21 ms | 24060 KB | n=100 |
10 | Correct | 23 ms | 24060 KB | n=100 |
11 | Correct | 24 ms | 24076 KB | n=100 |
12 | Correct | 21 ms | 24076 KB | n=100 |
13 | Correct | 21 ms | 24076 KB | n=100 |
14 | Correct | 22 ms | 24076 KB | n=100 |
15 | Correct | 22 ms | 24116 KB | n=100 |
16 | Correct | 25 ms | 24116 KB | n=100 |
17 | Correct | 21 ms | 24116 KB | n=100 |
18 | Correct | 22 ms | 24176 KB | n=100 |
19 | Correct | 24 ms | 24176 KB | n=100 |
20 | Correct | 22 ms | 24176 KB | n=100 |
21 | Correct | 21 ms | 24176 KB | n=100 |
22 | Correct | 21 ms | 24176 KB | n=100 |
23 | Correct | 21 ms | 24176 KB | n=100 |
24 | Correct | 21 ms | 24176 KB | n=100 |
25 | Correct | 22 ms | 24176 KB | n=100 |
26 | Correct | 22 ms | 24176 KB | n=12 |
27 | Correct | 22 ms | 24176 KB | n=100 |
28 | Correct | 22 ms | 24176 KB | n=500 |
29 | Correct | 24 ms | 24316 KB | n=500 |
30 | Correct | 26 ms | 24348 KB | n=500 |
31 | Correct | 22 ms | 24348 KB | n=500 |
32 | Correct | 24 ms | 24348 KB | n=500 |
33 | Correct | 22 ms | 24348 KB | n=500 |
34 | Correct | 23 ms | 24348 KB | n=500 |
35 | Correct | 24 ms | 24348 KB | n=500 |
36 | Correct | 22 ms | 24356 KB | n=500 |
37 | Correct | 22 ms | 24368 KB | n=500 |
38 | Correct | 23 ms | 24380 KB | n=500 |
39 | Correct | 22 ms | 24392 KB | n=500 |
40 | Correct | 22 ms | 24408 KB | n=500 |
41 | Correct | 23 ms | 24572 KB | n=500 |
42 | Correct | 23 ms | 24572 KB | n=500 |
43 | Correct | 23 ms | 24572 KB | n=500 |
44 | Correct | 22 ms | 24572 KB | n=500 |
45 | Correct | 23 ms | 24572 KB | n=500 |
46 | Correct | 23 ms | 24744 KB | n=500 |
47 | Correct | 24 ms | 24744 KB | n=500 |
48 | Correct | 23 ms | 24744 KB | n=500 |
49 | Correct | 23 ms | 24744 KB | n=500 |
50 | Correct | 23 ms | 24744 KB | n=500 |
51 | Correct | 23 ms | 24744 KB | n=500 |
52 | Correct | 26 ms | 24744 KB | n=500 |
53 | Correct | 22 ms | 24744 KB | n=500 |
54 | Correct | 23 ms | 24744 KB | n=500 |
55 | Correct | 22 ms | 24744 KB | n=278 |
56 | Correct | 23 ms | 24744 KB | n=500 |
57 | Correct | 22 ms | 24744 KB | n=500 |
58 | Correct | 22 ms | 24744 KB | n=500 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 23928 KB | n=5 |
2 | Correct | 22 ms | 24060 KB | n=100 |
3 | Correct | 22 ms | 24060 KB | n=100 |
4 | Correct | 21 ms | 24060 KB | n=100 |
5 | Correct | 21 ms | 24060 KB | n=100 |
6 | Correct | 21 ms | 24060 KB | n=100 |
7 | Correct | 21 ms | 24060 KB | n=100 |
8 | Correct | 22 ms | 24060 KB | n=100 |
9 | Correct | 21 ms | 24060 KB | n=100 |
10 | Correct | 23 ms | 24060 KB | n=100 |
11 | Correct | 24 ms | 24076 KB | n=100 |
12 | Correct | 21 ms | 24076 KB | n=100 |
13 | Correct | 21 ms | 24076 KB | n=100 |
14 | Correct | 22 ms | 24076 KB | n=100 |
15 | Correct | 22 ms | 24116 KB | n=100 |
16 | Correct | 25 ms | 24116 KB | n=100 |
17 | Correct | 21 ms | 24116 KB | n=100 |
18 | Correct | 22 ms | 24176 KB | n=100 |
19 | Correct | 24 ms | 24176 KB | n=100 |
20 | Correct | 22 ms | 24176 KB | n=100 |
21 | Correct | 21 ms | 24176 KB | n=100 |
22 | Correct | 21 ms | 24176 KB | n=100 |
23 | Correct | 21 ms | 24176 KB | n=100 |
24 | Correct | 21 ms | 24176 KB | n=100 |
25 | Correct | 22 ms | 24176 KB | n=100 |
26 | Correct | 22 ms | 24176 KB | n=12 |
27 | Correct | 22 ms | 24176 KB | n=100 |
28 | Correct | 22 ms | 24176 KB | n=500 |
29 | Correct | 24 ms | 24316 KB | n=500 |
30 | Correct | 26 ms | 24348 KB | n=500 |
31 | Correct | 22 ms | 24348 KB | n=500 |
32 | Correct | 24 ms | 24348 KB | n=500 |
33 | Correct | 22 ms | 24348 KB | n=500 |
34 | Correct | 23 ms | 24348 KB | n=500 |
35 | Correct | 24 ms | 24348 KB | n=500 |
36 | Correct | 22 ms | 24356 KB | n=500 |
37 | Correct | 22 ms | 24368 KB | n=500 |
38 | Correct | 23 ms | 24380 KB | n=500 |
39 | Correct | 22 ms | 24392 KB | n=500 |
40 | Correct | 22 ms | 24408 KB | n=500 |
41 | Correct | 23 ms | 24572 KB | n=500 |
42 | Correct | 23 ms | 24572 KB | n=500 |
43 | Correct | 23 ms | 24572 KB | n=500 |
44 | Correct | 22 ms | 24572 KB | n=500 |
45 | Correct | 23 ms | 24572 KB | n=500 |
46 | Correct | 23 ms | 24744 KB | n=500 |
47 | Correct | 24 ms | 24744 KB | n=500 |
48 | Correct | 23 ms | 24744 KB | n=500 |
49 | Correct | 23 ms | 24744 KB | n=500 |
50 | Correct | 23 ms | 24744 KB | n=500 |
51 | Correct | 23 ms | 24744 KB | n=500 |
52 | Correct | 26 ms | 24744 KB | n=500 |
53 | Correct | 22 ms | 24744 KB | n=500 |
54 | Correct | 23 ms | 24744 KB | n=500 |
55 | Correct | 22 ms | 24744 KB | n=278 |
56 | Correct | 23 ms | 24744 KB | n=500 |
57 | Correct | 22 ms | 24744 KB | n=500 |
58 | Correct | 22 ms | 24744 KB | n=500 |
59 | Correct | 26 ms | 25184 KB | n=2000 |
60 | Correct | 27 ms | 25392 KB | n=2000 |
61 | Correct | 27 ms | 25416 KB | n=2000 |
62 | Correct | 28 ms | 25416 KB | n=2000 |
63 | Correct | 27 ms | 25416 KB | n=2000 |
64 | Correct | 28 ms | 25492 KB | n=2000 |
65 | Correct | 30 ms | 25508 KB | n=2000 |
66 | Correct | 28 ms | 25688 KB | n=2000 |
67 | Correct | 29 ms | 25688 KB | n=2000 |
68 | Correct | 29 ms | 25708 KB | n=2000 |
69 | Correct | 25 ms | 25728 KB | n=2000 |
70 | Correct | 26 ms | 25780 KB | n=2000 |
71 | Correct | 27 ms | 25832 KB | n=2000 |
72 | Correct | 26 ms | 25912 KB | n=2000 |
73 | Correct | 26 ms | 25940 KB | n=2000 |
74 | Correct | 26 ms | 25996 KB | n=1844 |
75 | Correct | 26 ms | 26040 KB | n=2000 |
76 | Correct | 29 ms | 26132 KB | n=2000 |
77 | Correct | 27 ms | 26236 KB | n=2000 |
78 | Correct | 28 ms | 26236 KB | n=2000 |
79 | Correct | 28 ms | 26292 KB | n=2000 |
80 | Correct | 30 ms | 26372 KB | n=2000 |
81 | Correct | 29 ms | 26372 KB | n=2000 |
82 | Correct | 27 ms | 26496 KB | n=2000 |
83 | Correct | 28 ms | 26588 KB | n=2000 |
84 | Correct | 27 ms | 26588 KB | n=2000 |
85 | Correct | 27 ms | 26588 KB | n=2000 |
86 | Correct | 26 ms | 26624 KB | n=2000 |
87 | Correct | 27 ms | 26680 KB | n=2000 |
88 | Correct | 27 ms | 26888 KB | n=2000 |
89 | Correct | 27 ms | 26944 KB | n=2000 |
90 | Correct | 33 ms | 26972 KB | n=2000 |
91 | Correct | 26 ms | 26972 KB | n=2000 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 23928 KB | n=5 |
2 | Correct | 22 ms | 24060 KB | n=100 |
3 | Correct | 22 ms | 24060 KB | n=100 |
4 | Correct | 21 ms | 24060 KB | n=100 |
5 | Correct | 21 ms | 24060 KB | n=100 |
6 | Correct | 21 ms | 24060 KB | n=100 |
7 | Correct | 21 ms | 24060 KB | n=100 |
8 | Correct | 22 ms | 24060 KB | n=100 |
9 | Correct | 21 ms | 24060 KB | n=100 |
10 | Correct | 23 ms | 24060 KB | n=100 |
11 | Correct | 24 ms | 24076 KB | n=100 |
12 | Correct | 21 ms | 24076 KB | n=100 |
13 | Correct | 21 ms | 24076 KB | n=100 |
14 | Correct | 22 ms | 24076 KB | n=100 |
15 | Correct | 22 ms | 24116 KB | n=100 |
16 | Correct | 25 ms | 24116 KB | n=100 |
17 | Correct | 21 ms | 24116 KB | n=100 |
18 | Correct | 22 ms | 24176 KB | n=100 |
19 | Correct | 24 ms | 24176 KB | n=100 |
20 | Correct | 22 ms | 24176 KB | n=100 |
21 | Correct | 21 ms | 24176 KB | n=100 |
22 | Correct | 21 ms | 24176 KB | n=100 |
23 | Correct | 21 ms | 24176 KB | n=100 |
24 | Correct | 21 ms | 24176 KB | n=100 |
25 | Correct | 22 ms | 24176 KB | n=100 |
26 | Correct | 22 ms | 24176 KB | n=12 |
27 | Correct | 22 ms | 24176 KB | n=100 |
28 | Correct | 22 ms | 24176 KB | n=500 |
29 | Correct | 24 ms | 24316 KB | n=500 |
30 | Correct | 26 ms | 24348 KB | n=500 |
31 | Correct | 22 ms | 24348 KB | n=500 |
32 | Correct | 24 ms | 24348 KB | n=500 |
33 | Correct | 22 ms | 24348 KB | n=500 |
34 | Correct | 23 ms | 24348 KB | n=500 |
35 | Correct | 24 ms | 24348 KB | n=500 |
36 | Correct | 22 ms | 24356 KB | n=500 |
37 | Correct | 22 ms | 24368 KB | n=500 |
38 | Correct | 23 ms | 24380 KB | n=500 |
39 | Correct | 22 ms | 24392 KB | n=500 |
40 | Correct | 22 ms | 24408 KB | n=500 |
41 | Correct | 23 ms | 24572 KB | n=500 |
42 | Correct | 23 ms | 24572 KB | n=500 |
43 | Correct | 23 ms | 24572 KB | n=500 |
44 | Correct | 22 ms | 24572 KB | n=500 |
45 | Correct | 23 ms | 24572 KB | n=500 |
46 | Correct | 23 ms | 24744 KB | n=500 |
47 | Correct | 24 ms | 24744 KB | n=500 |
48 | Correct | 23 ms | 24744 KB | n=500 |
49 | Correct | 23 ms | 24744 KB | n=500 |
50 | Correct | 23 ms | 24744 KB | n=500 |
51 | Correct | 23 ms | 24744 KB | n=500 |
52 | Correct | 26 ms | 24744 KB | n=500 |
53 | Correct | 22 ms | 24744 KB | n=500 |
54 | Correct | 23 ms | 24744 KB | n=500 |
55 | Correct | 22 ms | 24744 KB | n=278 |
56 | Correct | 23 ms | 24744 KB | n=500 |
57 | Correct | 22 ms | 24744 KB | n=500 |
58 | Correct | 22 ms | 24744 KB | n=500 |
59 | Correct | 26 ms | 25184 KB | n=2000 |
60 | Correct | 27 ms | 25392 KB | n=2000 |
61 | Correct | 27 ms | 25416 KB | n=2000 |
62 | Correct | 28 ms | 25416 KB | n=2000 |
63 | Correct | 27 ms | 25416 KB | n=2000 |
64 | Correct | 28 ms | 25492 KB | n=2000 |
65 | Correct | 30 ms | 25508 KB | n=2000 |
66 | Correct | 28 ms | 25688 KB | n=2000 |
67 | Correct | 29 ms | 25688 KB | n=2000 |
68 | Correct | 29 ms | 25708 KB | n=2000 |
69 | Correct | 25 ms | 25728 KB | n=2000 |
70 | Correct | 26 ms | 25780 KB | n=2000 |
71 | Correct | 27 ms | 25832 KB | n=2000 |
72 | Correct | 26 ms | 25912 KB | n=2000 |
73 | Correct | 26 ms | 25940 KB | n=2000 |
74 | Correct | 26 ms | 25996 KB | n=1844 |
75 | Correct | 26 ms | 26040 KB | n=2000 |
76 | Correct | 29 ms | 26132 KB | n=2000 |
77 | Correct | 27 ms | 26236 KB | n=2000 |
78 | Correct | 28 ms | 26236 KB | n=2000 |
79 | Correct | 28 ms | 26292 KB | n=2000 |
80 | Correct | 30 ms | 26372 KB | n=2000 |
81 | Correct | 29 ms | 26372 KB | n=2000 |
82 | Correct | 27 ms | 26496 KB | n=2000 |
83 | Correct | 28 ms | 26588 KB | n=2000 |
84 | Correct | 27 ms | 26588 KB | n=2000 |
85 | Correct | 27 ms | 26588 KB | n=2000 |
86 | Correct | 26 ms | 26624 KB | n=2000 |
87 | Correct | 27 ms | 26680 KB | n=2000 |
88 | Correct | 27 ms | 26888 KB | n=2000 |
89 | Correct | 27 ms | 26944 KB | n=2000 |
90 | Correct | 33 ms | 26972 KB | n=2000 |
91 | Correct | 26 ms | 26972 KB | n=2000 |
92 | Correct | 1123 ms | 94484 KB | n=200000 |
93 | Correct | 1646 ms | 105776 KB | n=200000 |
94 | Correct | 1491 ms | 116800 KB | n=200000 |
95 | Correct | 1092 ms | 116800 KB | n=200000 |
96 | Correct | 1043 ms | 122516 KB | n=200000 |
97 | Correct | 1569 ms | 133396 KB | n=200000 |
98 | Correct | 1108 ms | 136700 KB | n=200000 |
99 | Correct | 1263 ms | 143452 KB | n=200000 |
100 | Correct | 1086 ms | 150504 KB | n=200000 |
101 | Correct | 1486 ms | 166444 KB | n=200000 |
102 | Correct | 670 ms | 166444 KB | n=200000 |
103 | Correct | 653 ms | 172272 KB | n=200000 |
104 | Correct | 660 ms | 179080 KB | n=200000 |
105 | Correct | 677 ms | 186044 KB | n=200000 |
106 | Correct | 694 ms | 193484 KB | n=200000 |
107 | Correct | 687 ms | 200784 KB | n=200000 |
108 | Correct | 1340 ms | 206560 KB | n=200000 |
109 | Correct | 1233 ms | 213712 KB | n=200000 |
110 | Correct | 1230 ms | 220588 KB | n=200000 |
111 | Correct | 1135 ms | 226732 KB | n=200000 |
112 | Correct | 1561 ms | 242008 KB | n=200000 |
113 | Correct | 1702 ms | 245156 KB | n=200000 |
114 | Correct | 1123 ms | 248252 KB | n=200000 |
115 | Correct | 1632 ms | 256772 KB | n=200000 |
116 | Runtime error | 1077 ms | 262596 KB | Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
117 | Halted | 0 ms | 0 KB | - |