# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133835 | 2019-07-21T13:51:34 Z | Kastanda | Birthday gift (IZhO18_treearray) | C++11 | 1454 ms | 82792 KB |
// ItnoE #include<bits/stdc++.h> using namespace std; const int N = 200005, LG = 18; int n, m, q, A[N], H[N], P[N][LG]; vector < int > Adj[N]; set < int > S[N], T[N]; void DFS(int v, int p) { for (int i = 1; i < LG; i ++) P[v][i] = P[P[v][i - 1]][i - 1]; for (int u : Adj[v]) if (u != p) { H[u] = H[v] + 1; P[u][0] = v; DFS(u, v); } } inline int LCA(int v, int u) { if (H[v] < H[u]) return (LCA(u, v)); for (int i = 0; i < LG; i ++) if ((H[v] - H[u]) & (1 << i)) v = P[v][i]; if (v == u) return (v); for (int i = LG - 1; ~ i; i --) if (P[v][i] != P[u][i]) v = P[v][i], u = P[u][i]; return (P[v][0]); } int main() { scanf("%d%d%d", &n, &m, &q); for (int i = 1; i < n; i ++) { int v, u; scanf("%d%d", &v, &u); Adj[v].push_back(u); Adj[u].push_back(v); } DFS(1, 0); for (int i = 1; i <= m; i ++) { scanf("%d", &A[i]); S[A[i]].insert(i); if (i > 1) T[LCA(A[i], A[i - 1])].insert(i - 1); } for (; q; q --) { int tp, l, r, v; scanf("%d", &tp); if (tp == 1) { scanf("%d%d", &l, &v); S[A[l]].erase(l); if (l > 1) T[LCA(A[l], A[l - 1])].erase(l - 1); if (l < m) T[LCA(A[l], A[l + 1])].erase(l); A[l] = v; S[A[l]].insert(l); if (l > 1) T[LCA(A[l], A[l - 1])].insert(l - 1); if (l < m) T[LCA(A[l], A[l + 1])].insert(l); } else { scanf("%d%d%d", &l, &r, &v); auto it = S[v].lower_bound(l); if (it != S[v].end() && (* it) <= r) { printf("%d %d\n", * it, * it); continue; } it = T[v].lower_bound(l); if (it != T[v].end() && (* it) + 1 <= r) printf("%d %d\n", * it, (* it) + 1); else printf("-1 -1\n"); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 23800 KB | n=5 |
2 | Correct | 23 ms | 23800 KB | n=100 |
3 | Correct | 24 ms | 23884 KB | n=100 |
4 | Correct | 24 ms | 23800 KB | n=100 |
5 | Correct | 24 ms | 23800 KB | n=100 |
6 | Correct | 24 ms | 23800 KB | n=100 |
7 | Correct | 24 ms | 23800 KB | n=100 |
8 | Correct | 23 ms | 23800 KB | n=100 |
9 | Correct | 23 ms | 23800 KB | n=100 |
10 | Correct | 24 ms | 23804 KB | n=100 |
11 | Correct | 23 ms | 23928 KB | n=100 |
12 | Correct | 23 ms | 23800 KB | n=100 |
13 | Correct | 24 ms | 23800 KB | n=100 |
14 | Correct | 24 ms | 23800 KB | n=100 |
15 | Correct | 23 ms | 23800 KB | n=100 |
16 | Correct | 23 ms | 23800 KB | n=100 |
17 | Correct | 24 ms | 23800 KB | n=100 |
18 | Correct | 23 ms | 23800 KB | n=100 |
19 | Correct | 24 ms | 23928 KB | n=100 |
20 | Correct | 29 ms | 23800 KB | n=100 |
21 | Correct | 29 ms | 23800 KB | n=100 |
22 | Correct | 29 ms | 23800 KB | n=100 |
23 | Correct | 24 ms | 23772 KB | n=100 |
24 | Correct | 24 ms | 23800 KB | n=100 |
25 | Correct | 23 ms | 23800 KB | n=100 |
26 | Correct | 23 ms | 23800 KB | n=12 |
27 | Correct | 23 ms | 23800 KB | n=100 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 23800 KB | n=5 |
2 | Correct | 23 ms | 23800 KB | n=100 |
3 | Correct | 24 ms | 23884 KB | n=100 |
4 | Correct | 24 ms | 23800 KB | n=100 |
5 | Correct | 24 ms | 23800 KB | n=100 |
6 | Correct | 24 ms | 23800 KB | n=100 |
7 | Correct | 24 ms | 23800 KB | n=100 |
8 | Correct | 23 ms | 23800 KB | n=100 |
9 | Correct | 23 ms | 23800 KB | n=100 |
10 | Correct | 24 ms | 23804 KB | n=100 |
11 | Correct | 23 ms | 23928 KB | n=100 |
12 | Correct | 23 ms | 23800 KB | n=100 |
13 | Correct | 24 ms | 23800 KB | n=100 |
14 | Correct | 24 ms | 23800 KB | n=100 |
15 | Correct | 23 ms | 23800 KB | n=100 |
16 | Correct | 23 ms | 23800 KB | n=100 |
17 | Correct | 24 ms | 23800 KB | n=100 |
18 | Correct | 23 ms | 23800 KB | n=100 |
19 | Correct | 24 ms | 23928 KB | n=100 |
20 | Correct | 29 ms | 23800 KB | n=100 |
21 | Correct | 29 ms | 23800 KB | n=100 |
22 | Correct | 29 ms | 23800 KB | n=100 |
23 | Correct | 24 ms | 23772 KB | n=100 |
24 | Correct | 24 ms | 23800 KB | n=100 |
25 | Correct | 23 ms | 23800 KB | n=100 |
26 | Correct | 23 ms | 23800 KB | n=12 |
27 | Correct | 23 ms | 23800 KB | n=100 |
28 | Correct | 24 ms | 23928 KB | n=500 |
29 | Correct | 24 ms | 23928 KB | n=500 |
30 | Correct | 24 ms | 23928 KB | n=500 |
31 | Correct | 24 ms | 23928 KB | n=500 |
32 | Correct | 25 ms | 23964 KB | n=500 |
33 | Correct | 24 ms | 23928 KB | n=500 |
34 | Correct | 25 ms | 23928 KB | n=500 |
35 | Correct | 24 ms | 23928 KB | n=500 |
36 | Correct | 25 ms | 23932 KB | n=500 |
37 | Correct | 24 ms | 23928 KB | n=500 |
38 | Correct | 24 ms | 23928 KB | n=500 |
39 | Correct | 25 ms | 23928 KB | n=500 |
40 | Correct | 25 ms | 23928 KB | n=500 |
41 | Correct | 24 ms | 23928 KB | n=500 |
42 | Correct | 24 ms | 23928 KB | n=500 |
43 | Correct | 24 ms | 23928 KB | n=500 |
44 | Correct | 24 ms | 23928 KB | n=500 |
45 | Correct | 24 ms | 23928 KB | n=500 |
46 | Correct | 25 ms | 23928 KB | n=500 |
47 | Correct | 24 ms | 23928 KB | n=500 |
48 | Correct | 24 ms | 23928 KB | n=500 |
49 | Correct | 25 ms | 23928 KB | n=500 |
50 | Correct | 27 ms | 23928 KB | n=500 |
51 | Correct | 25 ms | 23868 KB | n=500 |
52 | Correct | 25 ms | 23928 KB | n=500 |
53 | Correct | 25 ms | 23952 KB | n=500 |
54 | Correct | 25 ms | 23928 KB | n=500 |
55 | Correct | 24 ms | 23928 KB | n=278 |
56 | Correct | 25 ms | 24000 KB | n=500 |
57 | Correct | 24 ms | 23900 KB | n=500 |
58 | Correct | 24 ms | 23928 KB | n=500 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 23800 KB | n=5 |
2 | Correct | 23 ms | 23800 KB | n=100 |
3 | Correct | 24 ms | 23884 KB | n=100 |
4 | Correct | 24 ms | 23800 KB | n=100 |
5 | Correct | 24 ms | 23800 KB | n=100 |
6 | Correct | 24 ms | 23800 KB | n=100 |
7 | Correct | 24 ms | 23800 KB | n=100 |
8 | Correct | 23 ms | 23800 KB | n=100 |
9 | Correct | 23 ms | 23800 KB | n=100 |
10 | Correct | 24 ms | 23804 KB | n=100 |
11 | Correct | 23 ms | 23928 KB | n=100 |
12 | Correct | 23 ms | 23800 KB | n=100 |
13 | Correct | 24 ms | 23800 KB | n=100 |
14 | Correct | 24 ms | 23800 KB | n=100 |
15 | Correct | 23 ms | 23800 KB | n=100 |
16 | Correct | 23 ms | 23800 KB | n=100 |
17 | Correct | 24 ms | 23800 KB | n=100 |
18 | Correct | 23 ms | 23800 KB | n=100 |
19 | Correct | 24 ms | 23928 KB | n=100 |
20 | Correct | 29 ms | 23800 KB | n=100 |
21 | Correct | 29 ms | 23800 KB | n=100 |
22 | Correct | 29 ms | 23800 KB | n=100 |
23 | Correct | 24 ms | 23772 KB | n=100 |
24 | Correct | 24 ms | 23800 KB | n=100 |
25 | Correct | 23 ms | 23800 KB | n=100 |
26 | Correct | 23 ms | 23800 KB | n=12 |
27 | Correct | 23 ms | 23800 KB | n=100 |
28 | Correct | 24 ms | 23928 KB | n=500 |
29 | Correct | 24 ms | 23928 KB | n=500 |
30 | Correct | 24 ms | 23928 KB | n=500 |
31 | Correct | 24 ms | 23928 KB | n=500 |
32 | Correct | 25 ms | 23964 KB | n=500 |
33 | Correct | 24 ms | 23928 KB | n=500 |
34 | Correct | 25 ms | 23928 KB | n=500 |
35 | Correct | 24 ms | 23928 KB | n=500 |
36 | Correct | 25 ms | 23932 KB | n=500 |
37 | Correct | 24 ms | 23928 KB | n=500 |
38 | Correct | 24 ms | 23928 KB | n=500 |
39 | Correct | 25 ms | 23928 KB | n=500 |
40 | Correct | 25 ms | 23928 KB | n=500 |
41 | Correct | 24 ms | 23928 KB | n=500 |
42 | Correct | 24 ms | 23928 KB | n=500 |
43 | Correct | 24 ms | 23928 KB | n=500 |
44 | Correct | 24 ms | 23928 KB | n=500 |
45 | Correct | 24 ms | 23928 KB | n=500 |
46 | Correct | 25 ms | 23928 KB | n=500 |
47 | Correct | 24 ms | 23928 KB | n=500 |
48 | Correct | 24 ms | 23928 KB | n=500 |
49 | Correct | 25 ms | 23928 KB | n=500 |
50 | Correct | 27 ms | 23928 KB | n=500 |
51 | Correct | 25 ms | 23868 KB | n=500 |
52 | Correct | 25 ms | 23928 KB | n=500 |
53 | Correct | 25 ms | 23952 KB | n=500 |
54 | Correct | 25 ms | 23928 KB | n=500 |
55 | Correct | 24 ms | 23928 KB | n=278 |
56 | Correct | 25 ms | 24000 KB | n=500 |
57 | Correct | 24 ms | 23900 KB | n=500 |
58 | Correct | 24 ms | 23928 KB | n=500 |
59 | Correct | 28 ms | 24312 KB | n=2000 |
60 | Correct | 28 ms | 24440 KB | n=2000 |
61 | Correct | 28 ms | 24312 KB | n=2000 |
62 | Correct | 28 ms | 24312 KB | n=2000 |
63 | Correct | 28 ms | 24312 KB | n=2000 |
64 | Correct | 29 ms | 24312 KB | n=2000 |
65 | Correct | 28 ms | 24312 KB | n=2000 |
66 | Correct | 29 ms | 24312 KB | n=2000 |
67 | Correct | 29 ms | 24312 KB | n=2000 |
68 | Correct | 28 ms | 24312 KB | n=2000 |
69 | Correct | 27 ms | 24312 KB | n=2000 |
70 | Correct | 27 ms | 24312 KB | n=2000 |
71 | Correct | 27 ms | 24312 KB | n=2000 |
72 | Correct | 27 ms | 24312 KB | n=2000 |
73 | Correct | 27 ms | 24312 KB | n=2000 |
74 | Correct | 27 ms | 24312 KB | n=1844 |
75 | Correct | 27 ms | 24316 KB | n=2000 |
76 | Correct | 29 ms | 24312 KB | n=2000 |
77 | Correct | 28 ms | 24312 KB | n=2000 |
78 | Correct | 28 ms | 24312 KB | n=2000 |
79 | Correct | 28 ms | 24312 KB | n=2000 |
80 | Correct | 28 ms | 24316 KB | n=2000 |
81 | Correct | 29 ms | 24312 KB | n=2000 |
82 | Correct | 28 ms | 24312 KB | n=2000 |
83 | Correct | 28 ms | 24312 KB | n=2000 |
84 | Correct | 28 ms | 24440 KB | n=2000 |
85 | Correct | 28 ms | 24312 KB | n=2000 |
86 | Correct | 28 ms | 24312 KB | n=2000 |
87 | Correct | 28 ms | 24312 KB | n=2000 |
88 | Correct | 28 ms | 24440 KB | n=2000 |
89 | Correct | 28 ms | 24312 KB | n=2000 |
90 | Correct | 28 ms | 24312 KB | n=2000 |
91 | Correct | 33 ms | 24312 KB | n=2000 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 23800 KB | n=5 |
2 | Correct | 23 ms | 23800 KB | n=100 |
3 | Correct | 24 ms | 23884 KB | n=100 |
4 | Correct | 24 ms | 23800 KB | n=100 |
5 | Correct | 24 ms | 23800 KB | n=100 |
6 | Correct | 24 ms | 23800 KB | n=100 |
7 | Correct | 24 ms | 23800 KB | n=100 |
8 | Correct | 23 ms | 23800 KB | n=100 |
9 | Correct | 23 ms | 23800 KB | n=100 |
10 | Correct | 24 ms | 23804 KB | n=100 |
11 | Correct | 23 ms | 23928 KB | n=100 |
12 | Correct | 23 ms | 23800 KB | n=100 |
13 | Correct | 24 ms | 23800 KB | n=100 |
14 | Correct | 24 ms | 23800 KB | n=100 |
15 | Correct | 23 ms | 23800 KB | n=100 |
16 | Correct | 23 ms | 23800 KB | n=100 |
17 | Correct | 24 ms | 23800 KB | n=100 |
18 | Correct | 23 ms | 23800 KB | n=100 |
19 | Correct | 24 ms | 23928 KB | n=100 |
20 | Correct | 29 ms | 23800 KB | n=100 |
21 | Correct | 29 ms | 23800 KB | n=100 |
22 | Correct | 29 ms | 23800 KB | n=100 |
23 | Correct | 24 ms | 23772 KB | n=100 |
24 | Correct | 24 ms | 23800 KB | n=100 |
25 | Correct | 23 ms | 23800 KB | n=100 |
26 | Correct | 23 ms | 23800 KB | n=12 |
27 | Correct | 23 ms | 23800 KB | n=100 |
28 | Correct | 24 ms | 23928 KB | n=500 |
29 | Correct | 24 ms | 23928 KB | n=500 |
30 | Correct | 24 ms | 23928 KB | n=500 |
31 | Correct | 24 ms | 23928 KB | n=500 |
32 | Correct | 25 ms | 23964 KB | n=500 |
33 | Correct | 24 ms | 23928 KB | n=500 |
34 | Correct | 25 ms | 23928 KB | n=500 |
35 | Correct | 24 ms | 23928 KB | n=500 |
36 | Correct | 25 ms | 23932 KB | n=500 |
37 | Correct | 24 ms | 23928 KB | n=500 |
38 | Correct | 24 ms | 23928 KB | n=500 |
39 | Correct | 25 ms | 23928 KB | n=500 |
40 | Correct | 25 ms | 23928 KB | n=500 |
41 | Correct | 24 ms | 23928 KB | n=500 |
42 | Correct | 24 ms | 23928 KB | n=500 |
43 | Correct | 24 ms | 23928 KB | n=500 |
44 | Correct | 24 ms | 23928 KB | n=500 |
45 | Correct | 24 ms | 23928 KB | n=500 |
46 | Correct | 25 ms | 23928 KB | n=500 |
47 | Correct | 24 ms | 23928 KB | n=500 |
48 | Correct | 24 ms | 23928 KB | n=500 |
49 | Correct | 25 ms | 23928 KB | n=500 |
50 | Correct | 27 ms | 23928 KB | n=500 |
51 | Correct | 25 ms | 23868 KB | n=500 |
52 | Correct | 25 ms | 23928 KB | n=500 |
53 | Correct | 25 ms | 23952 KB | n=500 |
54 | Correct | 25 ms | 23928 KB | n=500 |
55 | Correct | 24 ms | 23928 KB | n=278 |
56 | Correct | 25 ms | 24000 KB | n=500 |
57 | Correct | 24 ms | 23900 KB | n=500 |
58 | Correct | 24 ms | 23928 KB | n=500 |
59 | Correct | 28 ms | 24312 KB | n=2000 |
60 | Correct | 28 ms | 24440 KB | n=2000 |
61 | Correct | 28 ms | 24312 KB | n=2000 |
62 | Correct | 28 ms | 24312 KB | n=2000 |
63 | Correct | 28 ms | 24312 KB | n=2000 |
64 | Correct | 29 ms | 24312 KB | n=2000 |
65 | Correct | 28 ms | 24312 KB | n=2000 |
66 | Correct | 29 ms | 24312 KB | n=2000 |
67 | Correct | 29 ms | 24312 KB | n=2000 |
68 | Correct | 28 ms | 24312 KB | n=2000 |
69 | Correct | 27 ms | 24312 KB | n=2000 |
70 | Correct | 27 ms | 24312 KB | n=2000 |
71 | Correct | 27 ms | 24312 KB | n=2000 |
72 | Correct | 27 ms | 24312 KB | n=2000 |
73 | Correct | 27 ms | 24312 KB | n=2000 |
74 | Correct | 27 ms | 24312 KB | n=1844 |
75 | Correct | 27 ms | 24316 KB | n=2000 |
76 | Correct | 29 ms | 24312 KB | n=2000 |
77 | Correct | 28 ms | 24312 KB | n=2000 |
78 | Correct | 28 ms | 24312 KB | n=2000 |
79 | Correct | 28 ms | 24312 KB | n=2000 |
80 | Correct | 28 ms | 24316 KB | n=2000 |
81 | Correct | 29 ms | 24312 KB | n=2000 |
82 | Correct | 28 ms | 24312 KB | n=2000 |
83 | Correct | 28 ms | 24312 KB | n=2000 |
84 | Correct | 28 ms | 24440 KB | n=2000 |
85 | Correct | 28 ms | 24312 KB | n=2000 |
86 | Correct | 28 ms | 24312 KB | n=2000 |
87 | Correct | 28 ms | 24312 KB | n=2000 |
88 | Correct | 28 ms | 24440 KB | n=2000 |
89 | Correct | 28 ms | 24312 KB | n=2000 |
90 | Correct | 28 ms | 24312 KB | n=2000 |
91 | Correct | 33 ms | 24312 KB | n=2000 |
92 | Correct | 960 ms | 73052 KB | n=200000 |
93 | Correct | 1338 ms | 78072 KB | n=200000 |
94 | Correct | 1249 ms | 81400 KB | n=200000 |
95 | Correct | 970 ms | 72912 KB | n=200000 |
96 | Correct | 872 ms | 72960 KB | n=200000 |
97 | Correct | 1275 ms | 77096 KB | n=200000 |
98 | Correct | 1020 ms | 73064 KB | n=200000 |
99 | Correct | 1126 ms | 73208 KB | n=200000 |
100 | Correct | 969 ms | 72916 KB | n=200000 |
101 | Correct | 1339 ms | 82792 KB | n=200000 |
102 | Correct | 615 ms | 74104 KB | n=200000 |
103 | Correct | 586 ms | 74136 KB | n=200000 |
104 | Correct | 588 ms | 74104 KB | n=200000 |
105 | Correct | 604 ms | 74448 KB | n=200000 |
106 | Correct | 603 ms | 74360 KB | n=200000 |
107 | Correct | 613 ms | 74560 KB | n=200000 |
108 | Correct | 1088 ms | 73008 KB | n=200000 |
109 | Correct | 1063 ms | 73004 KB | n=200000 |
110 | Correct | 1073 ms | 72984 KB | n=200000 |
111 | Correct | 960 ms | 72428 KB | n=200000 |
112 | Correct | 1326 ms | 81604 KB | n=200000 |
113 | Correct | 1309 ms | 77092 KB | n=200000 |
114 | Correct | 943 ms | 72428 KB | n=200000 |
115 | Correct | 1332 ms | 75000 KB | n=200000 |
116 | Correct | 912 ms | 73068 KB | n=200000 |
117 | Correct | 1255 ms | 81912 KB | n=200000 |
118 | Correct | 1454 ms | 76060 KB | n=200000 |
119 | Correct | 857 ms | 72988 KB | n=200000 |
120 | Correct | 1233 ms | 81624 KB | n=200000 |
121 | Correct | 1186 ms | 81764 KB | n=200000 |
122 | Correct | 1211 ms | 82044 KB | n=200000 |
123 | Correct | 618 ms | 74252 KB | n=200000 |
124 | Correct | 319 ms | 38776 KB | n=25264 |