# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83209 | 2018-11-06T03:38:13 Z | Good | Birthday gift (IZhO18_treearray) | C++11 | 2299 ms | 263168 KB |
/* ID: blackha5 TASK: test LANG: C++ */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define ff first #define ss second #define Maxn 200003 #define ll long long #define pb push_back #define Inf 1000000009 #define ppb() pop_back() #define pii pair <int , int> #define mid(x, y) (x + y) / 2 #define all(x) x.begin(),x.end() #define llInf 1000000000000000009 #define tr(i, c) for(__typeof(c).begin() i = (c).begin() ; i != (c).end() ; i++) using namespace std; using namespace __gnu_pbds; typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> order; int n, m, q; int A[Maxn]; int lvl[Maxn]; int mat[Maxn][21]; vector <int> adj[Maxn]; set <int> s[Maxn], t[Maxn]; void dfs (int nd, int p) { mat[nd][0] = p; lvl[nd] = lvl[p] + 1; for (auto i: adj[nd]) if (i != p) dfs (i, nd); } void build () { for (int i = 1; i <= 19; i++) for (int j = 1; j <= n; j++) mat[j][i] = mat[mat[j][i - 1]][i - 1]; } int lca (int x, int y) { if (lvl[x] < lvl[y]) swap (x, y); for (int i = 19; i >= 0; i--) if (lvl[mat[x][i]] >= lvl[y]) x = mat[x][i]; if (x == y) return x; for (int i = 19; i >= 0; i--) if (mat[x][i] != mat[y][i]) x = mat[x][i], y = mat[y][i]; return mat[x][0]; } int main () { //freopen ("file.in", "r", stdin); //freopen ("file.out", "w", stdout); //srand ((unsigned) time ( NULL )); //int randomNumber = rand() % 10 + 1; scanf ("%d%d%d", &n, &m, &q); for (int i = 1; i < n; i++) { int u, v; scanf ("%d%d", &u, &v); adj[u].pb (v); adj[v].pb (u); s[i].insert (Inf); t[i].insert (Inf); } s[n].insert (Inf); t[n].insert (Inf); dfs (1, 0); build (); for (int i = 1; i <= m; i++) { scanf ("%d", A + i); t[A[i]].insert (i); } for (int i = 1; i < m; i++) s[lca (A[i], A[i + 1])].insert (i); while (q--) { int type, l, v; scanf ("%d%d", &type, &l); if (type == 2) { int r; scanf ("%d%d", &r, &v); int x = *s[v].lower_bound (l); int y = *t[v].lower_bound (l); if (y <= r) printf ("%d %d\n", y, y); else if (x <= r - 1) printf ("%d %d\n", x, x + 1); else puts ("-1 -1"); } else { scanf ("%d", &v); t[A[l]].erase (l); t[v].insert (l); if (l > 1) { int x = lca (A[l - 1], A[l]); s[x].erase (l - 1); x = lca (A[l - 1], v); s[x].insert(l - 1); } if (l < n) { int x = lca (A[l], A[l + 1]); s[x].erase (l); x = lca (v, A[l + 1]); s[x].insert (l); } A[l] = v; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 23800 KB | n=5 |
2 | Correct | 25 ms | 24052 KB | n=100 |
3 | Correct | 24 ms | 24140 KB | n=100 |
4 | Correct | 24 ms | 24252 KB | n=100 |
5 | Correct | 24 ms | 24252 KB | n=100 |
6 | Correct | 23 ms | 24252 KB | n=100 |
7 | Correct | 23 ms | 24252 KB | n=100 |
8 | Correct | 23 ms | 24312 KB | n=100 |
9 | Correct | 26 ms | 24312 KB | n=100 |
10 | Correct | 24 ms | 24352 KB | n=100 |
11 | Correct | 23 ms | 24408 KB | n=100 |
12 | Correct | 23 ms | 24436 KB | n=100 |
13 | Correct | 23 ms | 24436 KB | n=100 |
14 | Correct | 24 ms | 24436 KB | n=100 |
15 | Correct | 23 ms | 24436 KB | n=100 |
16 | Correct | 23 ms | 24436 KB | n=100 |
17 | Correct | 23 ms | 24436 KB | n=100 |
18 | Correct | 23 ms | 24436 KB | n=100 |
19 | Correct | 23 ms | 24436 KB | n=100 |
20 | Correct | 23 ms | 24436 KB | n=100 |
21 | Correct | 24 ms | 24436 KB | n=100 |
22 | Correct | 25 ms | 24436 KB | n=100 |
23 | Correct | 24 ms | 24436 KB | n=100 |
24 | Correct | 23 ms | 24436 KB | n=100 |
25 | Correct | 23 ms | 24436 KB | n=100 |
26 | Correct | 23 ms | 24436 KB | n=12 |
27 | Correct | 23 ms | 24436 KB | n=100 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 23800 KB | n=5 |
2 | Correct | 25 ms | 24052 KB | n=100 |
3 | Correct | 24 ms | 24140 KB | n=100 |
4 | Correct | 24 ms | 24252 KB | n=100 |
5 | Correct | 24 ms | 24252 KB | n=100 |
6 | Correct | 23 ms | 24252 KB | n=100 |
7 | Correct | 23 ms | 24252 KB | n=100 |
8 | Correct | 23 ms | 24312 KB | n=100 |
9 | Correct | 26 ms | 24312 KB | n=100 |
10 | Correct | 24 ms | 24352 KB | n=100 |
11 | Correct | 23 ms | 24408 KB | n=100 |
12 | Correct | 23 ms | 24436 KB | n=100 |
13 | Correct | 23 ms | 24436 KB | n=100 |
14 | Correct | 24 ms | 24436 KB | n=100 |
15 | Correct | 23 ms | 24436 KB | n=100 |
16 | Correct | 23 ms | 24436 KB | n=100 |
17 | Correct | 23 ms | 24436 KB | n=100 |
18 | Correct | 23 ms | 24436 KB | n=100 |
19 | Correct | 23 ms | 24436 KB | n=100 |
20 | Correct | 23 ms | 24436 KB | n=100 |
21 | Correct | 24 ms | 24436 KB | n=100 |
22 | Correct | 25 ms | 24436 KB | n=100 |
23 | Correct | 24 ms | 24436 KB | n=100 |
24 | Correct | 23 ms | 24436 KB | n=100 |
25 | Correct | 23 ms | 24436 KB | n=100 |
26 | Correct | 23 ms | 24436 KB | n=12 |
27 | Correct | 23 ms | 24436 KB | n=100 |
28 | Correct | 24 ms | 24500 KB | n=500 |
29 | Correct | 26 ms | 24640 KB | n=500 |
30 | Correct | 27 ms | 24672 KB | n=500 |
31 | Correct | 25 ms | 24672 KB | n=500 |
32 | Correct | 24 ms | 24672 KB | n=500 |
33 | Correct | 25 ms | 24672 KB | n=500 |
34 | Correct | 27 ms | 24672 KB | n=500 |
35 | Correct | 25 ms | 24776 KB | n=500 |
36 | Correct | 23 ms | 24776 KB | n=500 |
37 | Correct | 25 ms | 24776 KB | n=500 |
38 | Correct | 26 ms | 24828 KB | n=500 |
39 | Correct | 29 ms | 24828 KB | n=500 |
40 | Correct | 24 ms | 24828 KB | n=500 |
41 | Correct | 24 ms | 24860 KB | n=500 |
42 | Correct | 25 ms | 24860 KB | n=500 |
43 | Correct | 25 ms | 24860 KB | n=500 |
44 | Correct | 30 ms | 24916 KB | n=500 |
45 | Correct | 33 ms | 24916 KB | n=500 |
46 | Correct | 25 ms | 24916 KB | n=500 |
47 | Correct | 25 ms | 24916 KB | n=500 |
48 | Correct | 24 ms | 24916 KB | n=500 |
49 | Correct | 24 ms | 24916 KB | n=500 |
50 | Correct | 25 ms | 24916 KB | n=500 |
51 | Correct | 25 ms | 24916 KB | n=500 |
52 | Correct | 27 ms | 24916 KB | n=500 |
53 | Correct | 25 ms | 25036 KB | n=500 |
54 | Correct | 25 ms | 25036 KB | n=500 |
55 | Correct | 23 ms | 25036 KB | n=278 |
56 | Correct | 28 ms | 25036 KB | n=500 |
57 | Correct | 24 ms | 25036 KB | n=500 |
58 | Correct | 24 ms | 25036 KB | n=500 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 23800 KB | n=5 |
2 | Correct | 25 ms | 24052 KB | n=100 |
3 | Correct | 24 ms | 24140 KB | n=100 |
4 | Correct | 24 ms | 24252 KB | n=100 |
5 | Correct | 24 ms | 24252 KB | n=100 |
6 | Correct | 23 ms | 24252 KB | n=100 |
7 | Correct | 23 ms | 24252 KB | n=100 |
8 | Correct | 23 ms | 24312 KB | n=100 |
9 | Correct | 26 ms | 24312 KB | n=100 |
10 | Correct | 24 ms | 24352 KB | n=100 |
11 | Correct | 23 ms | 24408 KB | n=100 |
12 | Correct | 23 ms | 24436 KB | n=100 |
13 | Correct | 23 ms | 24436 KB | n=100 |
14 | Correct | 24 ms | 24436 KB | n=100 |
15 | Correct | 23 ms | 24436 KB | n=100 |
16 | Correct | 23 ms | 24436 KB | n=100 |
17 | Correct | 23 ms | 24436 KB | n=100 |
18 | Correct | 23 ms | 24436 KB | n=100 |
19 | Correct | 23 ms | 24436 KB | n=100 |
20 | Correct | 23 ms | 24436 KB | n=100 |
21 | Correct | 24 ms | 24436 KB | n=100 |
22 | Correct | 25 ms | 24436 KB | n=100 |
23 | Correct | 24 ms | 24436 KB | n=100 |
24 | Correct | 23 ms | 24436 KB | n=100 |
25 | Correct | 23 ms | 24436 KB | n=100 |
26 | Correct | 23 ms | 24436 KB | n=12 |
27 | Correct | 23 ms | 24436 KB | n=100 |
28 | Correct | 24 ms | 24500 KB | n=500 |
29 | Correct | 26 ms | 24640 KB | n=500 |
30 | Correct | 27 ms | 24672 KB | n=500 |
31 | Correct | 25 ms | 24672 KB | n=500 |
32 | Correct | 24 ms | 24672 KB | n=500 |
33 | Correct | 25 ms | 24672 KB | n=500 |
34 | Correct | 27 ms | 24672 KB | n=500 |
35 | Correct | 25 ms | 24776 KB | n=500 |
36 | Correct | 23 ms | 24776 KB | n=500 |
37 | Correct | 25 ms | 24776 KB | n=500 |
38 | Correct | 26 ms | 24828 KB | n=500 |
39 | Correct | 29 ms | 24828 KB | n=500 |
40 | Correct | 24 ms | 24828 KB | n=500 |
41 | Correct | 24 ms | 24860 KB | n=500 |
42 | Correct | 25 ms | 24860 KB | n=500 |
43 | Correct | 25 ms | 24860 KB | n=500 |
44 | Correct | 30 ms | 24916 KB | n=500 |
45 | Correct | 33 ms | 24916 KB | n=500 |
46 | Correct | 25 ms | 24916 KB | n=500 |
47 | Correct | 25 ms | 24916 KB | n=500 |
48 | Correct | 24 ms | 24916 KB | n=500 |
49 | Correct | 24 ms | 24916 KB | n=500 |
50 | Correct | 25 ms | 24916 KB | n=500 |
51 | Correct | 25 ms | 24916 KB | n=500 |
52 | Correct | 27 ms | 24916 KB | n=500 |
53 | Correct | 25 ms | 25036 KB | n=500 |
54 | Correct | 25 ms | 25036 KB | n=500 |
55 | Correct | 23 ms | 25036 KB | n=278 |
56 | Correct | 28 ms | 25036 KB | n=500 |
57 | Correct | 24 ms | 25036 KB | n=500 |
58 | Correct | 24 ms | 25036 KB | n=500 |
59 | Correct | 29 ms | 25508 KB | n=2000 |
60 | Correct | 30 ms | 25688 KB | n=2000 |
61 | Correct | 30 ms | 25772 KB | n=2000 |
62 | Correct | 29 ms | 25772 KB | n=2000 |
63 | Correct | 36 ms | 25772 KB | n=2000 |
64 | Correct | 31 ms | 25908 KB | n=2000 |
65 | Correct | 29 ms | 25908 KB | n=2000 |
66 | Correct | 30 ms | 26016 KB | n=2000 |
67 | Correct | 30 ms | 26052 KB | n=2000 |
68 | Correct | 31 ms | 26128 KB | n=2000 |
69 | Correct | 28 ms | 26128 KB | n=2000 |
70 | Correct | 27 ms | 26128 KB | n=2000 |
71 | Correct | 28 ms | 26160 KB | n=2000 |
72 | Correct | 28 ms | 26212 KB | n=2000 |
73 | Correct | 29 ms | 26380 KB | n=2000 |
74 | Correct | 28 ms | 26380 KB | n=1844 |
75 | Correct | 28 ms | 26428 KB | n=2000 |
76 | Correct | 29 ms | 26428 KB | n=2000 |
77 | Correct | 30 ms | 26476 KB | n=2000 |
78 | Correct | 33 ms | 26528 KB | n=2000 |
79 | Correct | 29 ms | 26580 KB | n=2000 |
80 | Correct | 32 ms | 26756 KB | n=2000 |
81 | Correct | 35 ms | 26896 KB | n=2000 |
82 | Correct | 29 ms | 26896 KB | n=2000 |
83 | Correct | 30 ms | 26936 KB | n=2000 |
84 | Correct | 38 ms | 26936 KB | n=2000 |
85 | Correct | 29 ms | 27028 KB | n=2000 |
86 | Correct | 30 ms | 27028 KB | n=2000 |
87 | Correct | 30 ms | 27140 KB | n=2000 |
88 | Correct | 28 ms | 27344 KB | n=2000 |
89 | Correct | 29 ms | 27344 KB | n=2000 |
90 | Correct | 31 ms | 27344 KB | n=2000 |
91 | Correct | 30 ms | 27352 KB | n=2000 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 23800 KB | n=5 |
2 | Correct | 25 ms | 24052 KB | n=100 |
3 | Correct | 24 ms | 24140 KB | n=100 |
4 | Correct | 24 ms | 24252 KB | n=100 |
5 | Correct | 24 ms | 24252 KB | n=100 |
6 | Correct | 23 ms | 24252 KB | n=100 |
7 | Correct | 23 ms | 24252 KB | n=100 |
8 | Correct | 23 ms | 24312 KB | n=100 |
9 | Correct | 26 ms | 24312 KB | n=100 |
10 | Correct | 24 ms | 24352 KB | n=100 |
11 | Correct | 23 ms | 24408 KB | n=100 |
12 | Correct | 23 ms | 24436 KB | n=100 |
13 | Correct | 23 ms | 24436 KB | n=100 |
14 | Correct | 24 ms | 24436 KB | n=100 |
15 | Correct | 23 ms | 24436 KB | n=100 |
16 | Correct | 23 ms | 24436 KB | n=100 |
17 | Correct | 23 ms | 24436 KB | n=100 |
18 | Correct | 23 ms | 24436 KB | n=100 |
19 | Correct | 23 ms | 24436 KB | n=100 |
20 | Correct | 23 ms | 24436 KB | n=100 |
21 | Correct | 24 ms | 24436 KB | n=100 |
22 | Correct | 25 ms | 24436 KB | n=100 |
23 | Correct | 24 ms | 24436 KB | n=100 |
24 | Correct | 23 ms | 24436 KB | n=100 |
25 | Correct | 23 ms | 24436 KB | n=100 |
26 | Correct | 23 ms | 24436 KB | n=12 |
27 | Correct | 23 ms | 24436 KB | n=100 |
28 | Correct | 24 ms | 24500 KB | n=500 |
29 | Correct | 26 ms | 24640 KB | n=500 |
30 | Correct | 27 ms | 24672 KB | n=500 |
31 | Correct | 25 ms | 24672 KB | n=500 |
32 | Correct | 24 ms | 24672 KB | n=500 |
33 | Correct | 25 ms | 24672 KB | n=500 |
34 | Correct | 27 ms | 24672 KB | n=500 |
35 | Correct | 25 ms | 24776 KB | n=500 |
36 | Correct | 23 ms | 24776 KB | n=500 |
37 | Correct | 25 ms | 24776 KB | n=500 |
38 | Correct | 26 ms | 24828 KB | n=500 |
39 | Correct | 29 ms | 24828 KB | n=500 |
40 | Correct | 24 ms | 24828 KB | n=500 |
41 | Correct | 24 ms | 24860 KB | n=500 |
42 | Correct | 25 ms | 24860 KB | n=500 |
43 | Correct | 25 ms | 24860 KB | n=500 |
44 | Correct | 30 ms | 24916 KB | n=500 |
45 | Correct | 33 ms | 24916 KB | n=500 |
46 | Correct | 25 ms | 24916 KB | n=500 |
47 | Correct | 25 ms | 24916 KB | n=500 |
48 | Correct | 24 ms | 24916 KB | n=500 |
49 | Correct | 24 ms | 24916 KB | n=500 |
50 | Correct | 25 ms | 24916 KB | n=500 |
51 | Correct | 25 ms | 24916 KB | n=500 |
52 | Correct | 27 ms | 24916 KB | n=500 |
53 | Correct | 25 ms | 25036 KB | n=500 |
54 | Correct | 25 ms | 25036 KB | n=500 |
55 | Correct | 23 ms | 25036 KB | n=278 |
56 | Correct | 28 ms | 25036 KB | n=500 |
57 | Correct | 24 ms | 25036 KB | n=500 |
58 | Correct | 24 ms | 25036 KB | n=500 |
59 | Correct | 29 ms | 25508 KB | n=2000 |
60 | Correct | 30 ms | 25688 KB | n=2000 |
61 | Correct | 30 ms | 25772 KB | n=2000 |
62 | Correct | 29 ms | 25772 KB | n=2000 |
63 | Correct | 36 ms | 25772 KB | n=2000 |
64 | Correct | 31 ms | 25908 KB | n=2000 |
65 | Correct | 29 ms | 25908 KB | n=2000 |
66 | Correct | 30 ms | 26016 KB | n=2000 |
67 | Correct | 30 ms | 26052 KB | n=2000 |
68 | Correct | 31 ms | 26128 KB | n=2000 |
69 | Correct | 28 ms | 26128 KB | n=2000 |
70 | Correct | 27 ms | 26128 KB | n=2000 |
71 | Correct | 28 ms | 26160 KB | n=2000 |
72 | Correct | 28 ms | 26212 KB | n=2000 |
73 | Correct | 29 ms | 26380 KB | n=2000 |
74 | Correct | 28 ms | 26380 KB | n=1844 |
75 | Correct | 28 ms | 26428 KB | n=2000 |
76 | Correct | 29 ms | 26428 KB | n=2000 |
77 | Correct | 30 ms | 26476 KB | n=2000 |
78 | Correct | 33 ms | 26528 KB | n=2000 |
79 | Correct | 29 ms | 26580 KB | n=2000 |
80 | Correct | 32 ms | 26756 KB | n=2000 |
81 | Correct | 35 ms | 26896 KB | n=2000 |
82 | Correct | 29 ms | 26896 KB | n=2000 |
83 | Correct | 30 ms | 26936 KB | n=2000 |
84 | Correct | 38 ms | 26936 KB | n=2000 |
85 | Correct | 29 ms | 27028 KB | n=2000 |
86 | Correct | 30 ms | 27028 KB | n=2000 |
87 | Correct | 30 ms | 27140 KB | n=2000 |
88 | Correct | 28 ms | 27344 KB | n=2000 |
89 | Correct | 29 ms | 27344 KB | n=2000 |
90 | Correct | 31 ms | 27344 KB | n=2000 |
91 | Correct | 30 ms | 27352 KB | n=2000 |
92 | Correct | 1352 ms | 96988 KB | n=200000 |
93 | Correct | 2012 ms | 108432 KB | n=200000 |
94 | Correct | 2017 ms | 119556 KB | n=200000 |
95 | Correct | 1340 ms | 119556 KB | n=200000 |
96 | Correct | 1296 ms | 125176 KB | n=200000 |
97 | Correct | 1891 ms | 135860 KB | n=200000 |
98 | Correct | 1294 ms | 139404 KB | n=200000 |
99 | Correct | 1533 ms | 145996 KB | n=200000 |
100 | Correct | 1449 ms | 153124 KB | n=200000 |
101 | Correct | 1947 ms | 169156 KB | n=200000 |
102 | Correct | 784 ms | 169156 KB | n=200000 |
103 | Correct | 733 ms | 175136 KB | n=200000 |
104 | Correct | 801 ms | 181764 KB | n=200000 |
105 | Correct | 748 ms | 188900 KB | n=200000 |
106 | Correct | 836 ms | 196100 KB | n=200000 |
107 | Correct | 869 ms | 203612 KB | n=200000 |
108 | Correct | 1331 ms | 209368 KB | n=200000 |
109 | Correct | 1360 ms | 216252 KB | n=200000 |
110 | Correct | 1380 ms | 223200 KB | n=200000 |
111 | Correct | 1383 ms | 229452 KB | n=200000 |
112 | Correct | 2053 ms | 244668 KB | n=200000 |
113 | Correct | 2033 ms | 247780 KB | n=200000 |
114 | Correct | 1354 ms | 250900 KB | n=200000 |
115 | Correct | 2299 ms | 259476 KB | n=200000 |
116 | Runtime error | 1280 ms | 263168 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 | - |