# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
672471 | 2022-12-16T10:17:46 Z | Cutebol | Birthday gift (IZhO18_treearray) | C++17 | 110 ms | 262144 KB |
#include <bits/stdc++.h> using namespace std; void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define Scaramouche ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0); #define int long long #define itn int #define endl "\n" #define ff first #define ss second const int N = 2e5 + 5 ; const int mod = 1e9 + 7 ; const int inf = 1e12 ; int n , m , q , l = 1 , timer ; int tin[N] , tout[N] , a[N] ; vector <int> g[N] , up[N] ; set <int> par[N] , st[N] ; void dfs( int v , int p = 1 ){ tin[v] = ++timer ; up[v][0] = p ; for ( int i = 1 ; i <= l ; i ++ ) up[v][i] = up[up[v][i-1]][i-1] ; for ( auto to : g[v] ){ if ( to != p ) 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 = l ; i >= 0 ; i -- ) if ( !upper(up[a][i] , b) ) a = up[a][i] ; return up[a][0] ; } void solve(){ cin >> n >> m >> q ; while ( ( 1 << l ) <= n ) l ++ ; for ( int i = 0 ; i <= n ; i ++ ) up[i].resize(n) ; for ( int i = 1 ; i < n ; i ++ ){ int x , y ; cin >> x >> y ; g[x].push_back(y) ; g[y].push_back(x) ; } for ( int i = 1 ; i <= m ; i ++ ){ cin >> a[i] ; st[a[i]].insert(i) ;} dfs(1) ; for ( int i = 2 ; i <= m ; i ++ ) par[lca(a[i],a[i-1])].insert(i-1) ; while ( q -- ){ // int x , y; // cin >> x >> y ; // cout << lca(x,y) << endl ; int tt ; cin >> tt ; if ( tt == 1 ){ int ind , val ; cin >> ind >> val ; st[a[ind]].erase(st[a[ind]].find(ind)) ; st[val].insert(ind) ; if ( ind > 1 ){ par[lca(a[ind],a[ind-1])].erase(ind-1) ; par[lca(val,a[ind-1])].insert(ind-1) ; } if ( ind < m ){ par[lca(a[ind],a[ind+1])].erase(ind) ; par[lca(val,a[ind+1])].insert(ind) ; } a[ind] = val ; } else{ int l , r , v ; cin >> l >> r >> v ; auto f = st[v].lower_bound(l) ; if ( f != st[v].end() && *f <= r ){ cout << *f << ' ' << *f << endl ; continue ; } f = par[v].lower_bound(l) ; if ( f != par[v].end() && *f < r ) cout << *f << ' ' << *f+1 << endl ; else cout << "-1 -1\n" ; } } } signed main(){ // fopn("blocks") ; Scaramouche ; int t = 1 ; // cin >> t ; while ( t -- ) solve() ; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 28500 KB | n=5 |
2 | Correct | 15 ms | 28544 KB | n=100 |
3 | Correct | 14 ms | 28492 KB | n=100 |
4 | Correct | 15 ms | 28620 KB | n=100 |
5 | Correct | 15 ms | 28608 KB | n=100 |
6 | Correct | 15 ms | 28500 KB | n=100 |
7 | Correct | 15 ms | 28500 KB | n=100 |
8 | Correct | 18 ms | 28500 KB | n=100 |
9 | Correct | 15 ms | 28500 KB | n=100 |
10 | Correct | 15 ms | 28500 KB | n=100 |
11 | Correct | 16 ms | 28620 KB | n=100 |
12 | Correct | 16 ms | 28544 KB | n=100 |
13 | Correct | 15 ms | 28612 KB | n=100 |
14 | Correct | 16 ms | 28500 KB | n=100 |
15 | Correct | 16 ms | 28620 KB | n=100 |
16 | Correct | 14 ms | 28504 KB | n=100 |
17 | Correct | 15 ms | 28540 KB | n=100 |
18 | Correct | 15 ms | 28644 KB | n=100 |
19 | Correct | 15 ms | 28500 KB | n=100 |
20 | Correct | 17 ms | 28632 KB | n=100 |
21 | Correct | 15 ms | 28500 KB | n=100 |
22 | Correct | 15 ms | 28620 KB | n=100 |
23 | Correct | 17 ms | 28500 KB | n=100 |
24 | Correct | 16 ms | 28516 KB | n=100 |
25 | Correct | 16 ms | 28500 KB | n=100 |
26 | Correct | 16 ms | 28448 KB | n=12 |
27 | Correct | 17 ms | 28544 KB | n=100 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 28500 KB | n=5 |
2 | Correct | 15 ms | 28544 KB | n=100 |
3 | Correct | 14 ms | 28492 KB | n=100 |
4 | Correct | 15 ms | 28620 KB | n=100 |
5 | Correct | 15 ms | 28608 KB | n=100 |
6 | Correct | 15 ms | 28500 KB | n=100 |
7 | Correct | 15 ms | 28500 KB | n=100 |
8 | Correct | 18 ms | 28500 KB | n=100 |
9 | Correct | 15 ms | 28500 KB | n=100 |
10 | Correct | 15 ms | 28500 KB | n=100 |
11 | Correct | 16 ms | 28620 KB | n=100 |
12 | Correct | 16 ms | 28544 KB | n=100 |
13 | Correct | 15 ms | 28612 KB | n=100 |
14 | Correct | 16 ms | 28500 KB | n=100 |
15 | Correct | 16 ms | 28620 KB | n=100 |
16 | Correct | 14 ms | 28504 KB | n=100 |
17 | Correct | 15 ms | 28540 KB | n=100 |
18 | Correct | 15 ms | 28644 KB | n=100 |
19 | Correct | 15 ms | 28500 KB | n=100 |
20 | Correct | 17 ms | 28632 KB | n=100 |
21 | Correct | 15 ms | 28500 KB | n=100 |
22 | Correct | 15 ms | 28620 KB | n=100 |
23 | Correct | 17 ms | 28500 KB | n=100 |
24 | Correct | 16 ms | 28516 KB | n=100 |
25 | Correct | 16 ms | 28500 KB | n=100 |
26 | Correct | 16 ms | 28448 KB | n=12 |
27 | Correct | 17 ms | 28544 KB | n=100 |
28 | Correct | 15 ms | 30548 KB | n=500 |
29 | Correct | 15 ms | 30548 KB | n=500 |
30 | Correct | 15 ms | 30528 KB | n=500 |
31 | Correct | 15 ms | 30484 KB | n=500 |
32 | Correct | 15 ms | 30572 KB | n=500 |
33 | Correct | 15 ms | 30548 KB | n=500 |
34 | Correct | 16 ms | 30512 KB | n=500 |
35 | Correct | 15 ms | 30568 KB | n=500 |
36 | Correct | 17 ms | 30560 KB | n=500 |
37 | Correct | 18 ms | 30548 KB | n=500 |
38 | Correct | 15 ms | 30548 KB | n=500 |
39 | Correct | 16 ms | 30536 KB | n=500 |
40 | Correct | 15 ms | 30548 KB | n=500 |
41 | Correct | 15 ms | 30576 KB | n=500 |
42 | Correct | 16 ms | 30492 KB | n=500 |
43 | Correct | 18 ms | 30576 KB | n=500 |
44 | Correct | 18 ms | 30548 KB | n=500 |
45 | Correct | 18 ms | 30548 KB | n=500 |
46 | Correct | 18 ms | 30568 KB | n=500 |
47 | Correct | 15 ms | 30568 KB | n=500 |
48 | Correct | 16 ms | 30588 KB | n=500 |
49 | Correct | 17 ms | 30492 KB | n=500 |
50 | Correct | 16 ms | 30572 KB | n=500 |
51 | Correct | 16 ms | 30520 KB | n=500 |
52 | Correct | 18 ms | 30536 KB | n=500 |
53 | Correct | 15 ms | 30492 KB | n=500 |
54 | Correct | 15 ms | 30548 KB | n=500 |
55 | Correct | 15 ms | 29140 KB | n=278 |
56 | Correct | 18 ms | 30564 KB | n=500 |
57 | Correct | 16 ms | 30568 KB | n=500 |
58 | Correct | 20 ms | 30696 KB | n=500 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 28500 KB | n=5 |
2 | Correct | 15 ms | 28544 KB | n=100 |
3 | Correct | 14 ms | 28492 KB | n=100 |
4 | Correct | 15 ms | 28620 KB | n=100 |
5 | Correct | 15 ms | 28608 KB | n=100 |
6 | Correct | 15 ms | 28500 KB | n=100 |
7 | Correct | 15 ms | 28500 KB | n=100 |
8 | Correct | 18 ms | 28500 KB | n=100 |
9 | Correct | 15 ms | 28500 KB | n=100 |
10 | Correct | 15 ms | 28500 KB | n=100 |
11 | Correct | 16 ms | 28620 KB | n=100 |
12 | Correct | 16 ms | 28544 KB | n=100 |
13 | Correct | 15 ms | 28612 KB | n=100 |
14 | Correct | 16 ms | 28500 KB | n=100 |
15 | Correct | 16 ms | 28620 KB | n=100 |
16 | Correct | 14 ms | 28504 KB | n=100 |
17 | Correct | 15 ms | 28540 KB | n=100 |
18 | Correct | 15 ms | 28644 KB | n=100 |
19 | Correct | 15 ms | 28500 KB | n=100 |
20 | Correct | 17 ms | 28632 KB | n=100 |
21 | Correct | 15 ms | 28500 KB | n=100 |
22 | Correct | 15 ms | 28620 KB | n=100 |
23 | Correct | 17 ms | 28500 KB | n=100 |
24 | Correct | 16 ms | 28516 KB | n=100 |
25 | Correct | 16 ms | 28500 KB | n=100 |
26 | Correct | 16 ms | 28448 KB | n=12 |
27 | Correct | 17 ms | 28544 KB | n=100 |
28 | Correct | 15 ms | 30548 KB | n=500 |
29 | Correct | 15 ms | 30548 KB | n=500 |
30 | Correct | 15 ms | 30528 KB | n=500 |
31 | Correct | 15 ms | 30484 KB | n=500 |
32 | Correct | 15 ms | 30572 KB | n=500 |
33 | Correct | 15 ms | 30548 KB | n=500 |
34 | Correct | 16 ms | 30512 KB | n=500 |
35 | Correct | 15 ms | 30568 KB | n=500 |
36 | Correct | 17 ms | 30560 KB | n=500 |
37 | Correct | 18 ms | 30548 KB | n=500 |
38 | Correct | 15 ms | 30548 KB | n=500 |
39 | Correct | 16 ms | 30536 KB | n=500 |
40 | Correct | 15 ms | 30548 KB | n=500 |
41 | Correct | 15 ms | 30576 KB | n=500 |
42 | Correct | 16 ms | 30492 KB | n=500 |
43 | Correct | 18 ms | 30576 KB | n=500 |
44 | Correct | 18 ms | 30548 KB | n=500 |
45 | Correct | 18 ms | 30548 KB | n=500 |
46 | Correct | 18 ms | 30568 KB | n=500 |
47 | Correct | 15 ms | 30568 KB | n=500 |
48 | Correct | 16 ms | 30588 KB | n=500 |
49 | Correct | 17 ms | 30492 KB | n=500 |
50 | Correct | 16 ms | 30572 KB | n=500 |
51 | Correct | 16 ms | 30520 KB | n=500 |
52 | Correct | 18 ms | 30536 KB | n=500 |
53 | Correct | 15 ms | 30492 KB | n=500 |
54 | Correct | 15 ms | 30548 KB | n=500 |
55 | Correct | 15 ms | 29140 KB | n=278 |
56 | Correct | 18 ms | 30564 KB | n=500 |
57 | Correct | 16 ms | 30568 KB | n=500 |
58 | Correct | 20 ms | 30696 KB | n=500 |
59 | Correct | 29 ms | 60244 KB | n=2000 |
60 | Correct | 28 ms | 60236 KB | n=2000 |
61 | Correct | 31 ms | 60188 KB | n=2000 |
62 | Correct | 28 ms | 60236 KB | n=2000 |
63 | Correct | 29 ms | 60236 KB | n=2000 |
64 | Correct | 30 ms | 60268 KB | n=2000 |
65 | Correct | 36 ms | 60216 KB | n=2000 |
66 | Correct | 33 ms | 60244 KB | n=2000 |
67 | Correct | 29 ms | 60244 KB | n=2000 |
68 | Correct | 32 ms | 60248 KB | n=2000 |
69 | Correct | 30 ms | 60244 KB | n=2000 |
70 | Correct | 29 ms | 60140 KB | n=2000 |
71 | Correct | 30 ms | 60232 KB | n=2000 |
72 | Correct | 28 ms | 60164 KB | n=2000 |
73 | Correct | 28 ms | 60244 KB | n=2000 |
74 | Correct | 27 ms | 55528 KB | n=1844 |
75 | Correct | 29 ms | 60244 KB | n=2000 |
76 | Correct | 31 ms | 60108 KB | n=2000 |
77 | Correct | 30 ms | 60128 KB | n=2000 |
78 | Correct | 34 ms | 60212 KB | n=2000 |
79 | Correct | 29 ms | 60108 KB | n=2000 |
80 | Correct | 30 ms | 60256 KB | n=2000 |
81 | Correct | 30 ms | 60264 KB | n=2000 |
82 | Correct | 29 ms | 60236 KB | n=2000 |
83 | Correct | 29 ms | 60236 KB | n=2000 |
84 | Correct | 30 ms | 60232 KB | n=2000 |
85 | Correct | 30 ms | 60244 KB | n=2000 |
86 | Correct | 31 ms | 60264 KB | n=2000 |
87 | Correct | 30 ms | 60216 KB | n=2000 |
88 | Correct | 32 ms | 60256 KB | n=2000 |
89 | Correct | 29 ms | 60244 KB | n=2000 |
90 | Correct | 32 ms | 60220 KB | n=2000 |
91 | Correct | 29 ms | 60120 KB | n=2000 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 28500 KB | n=5 |
2 | Correct | 15 ms | 28544 KB | n=100 |
3 | Correct | 14 ms | 28492 KB | n=100 |
4 | Correct | 15 ms | 28620 KB | n=100 |
5 | Correct | 15 ms | 28608 KB | n=100 |
6 | Correct | 15 ms | 28500 KB | n=100 |
7 | Correct | 15 ms | 28500 KB | n=100 |
8 | Correct | 18 ms | 28500 KB | n=100 |
9 | Correct | 15 ms | 28500 KB | n=100 |
10 | Correct | 15 ms | 28500 KB | n=100 |
11 | Correct | 16 ms | 28620 KB | n=100 |
12 | Correct | 16 ms | 28544 KB | n=100 |
13 | Correct | 15 ms | 28612 KB | n=100 |
14 | Correct | 16 ms | 28500 KB | n=100 |
15 | Correct | 16 ms | 28620 KB | n=100 |
16 | Correct | 14 ms | 28504 KB | n=100 |
17 | Correct | 15 ms | 28540 KB | n=100 |
18 | Correct | 15 ms | 28644 KB | n=100 |
19 | Correct | 15 ms | 28500 KB | n=100 |
20 | Correct | 17 ms | 28632 KB | n=100 |
21 | Correct | 15 ms | 28500 KB | n=100 |
22 | Correct | 15 ms | 28620 KB | n=100 |
23 | Correct | 17 ms | 28500 KB | n=100 |
24 | Correct | 16 ms | 28516 KB | n=100 |
25 | Correct | 16 ms | 28500 KB | n=100 |
26 | Correct | 16 ms | 28448 KB | n=12 |
27 | Correct | 17 ms | 28544 KB | n=100 |
28 | Correct | 15 ms | 30548 KB | n=500 |
29 | Correct | 15 ms | 30548 KB | n=500 |
30 | Correct | 15 ms | 30528 KB | n=500 |
31 | Correct | 15 ms | 30484 KB | n=500 |
32 | Correct | 15 ms | 30572 KB | n=500 |
33 | Correct | 15 ms | 30548 KB | n=500 |
34 | Correct | 16 ms | 30512 KB | n=500 |
35 | Correct | 15 ms | 30568 KB | n=500 |
36 | Correct | 17 ms | 30560 KB | n=500 |
37 | Correct | 18 ms | 30548 KB | n=500 |
38 | Correct | 15 ms | 30548 KB | n=500 |
39 | Correct | 16 ms | 30536 KB | n=500 |
40 | Correct | 15 ms | 30548 KB | n=500 |
41 | Correct | 15 ms | 30576 KB | n=500 |
42 | Correct | 16 ms | 30492 KB | n=500 |
43 | Correct | 18 ms | 30576 KB | n=500 |
44 | Correct | 18 ms | 30548 KB | n=500 |
45 | Correct | 18 ms | 30548 KB | n=500 |
46 | Correct | 18 ms | 30568 KB | n=500 |
47 | Correct | 15 ms | 30568 KB | n=500 |
48 | Correct | 16 ms | 30588 KB | n=500 |
49 | Correct | 17 ms | 30492 KB | n=500 |
50 | Correct | 16 ms | 30572 KB | n=500 |
51 | Correct | 16 ms | 30520 KB | n=500 |
52 | Correct | 18 ms | 30536 KB | n=500 |
53 | Correct | 15 ms | 30492 KB | n=500 |
54 | Correct | 15 ms | 30548 KB | n=500 |
55 | Correct | 15 ms | 29140 KB | n=278 |
56 | Correct | 18 ms | 30564 KB | n=500 |
57 | Correct | 16 ms | 30568 KB | n=500 |
58 | Correct | 20 ms | 30696 KB | n=500 |
59 | Correct | 29 ms | 60244 KB | n=2000 |
60 | Correct | 28 ms | 60236 KB | n=2000 |
61 | Correct | 31 ms | 60188 KB | n=2000 |
62 | Correct | 28 ms | 60236 KB | n=2000 |
63 | Correct | 29 ms | 60236 KB | n=2000 |
64 | Correct | 30 ms | 60268 KB | n=2000 |
65 | Correct | 36 ms | 60216 KB | n=2000 |
66 | Correct | 33 ms | 60244 KB | n=2000 |
67 | Correct | 29 ms | 60244 KB | n=2000 |
68 | Correct | 32 ms | 60248 KB | n=2000 |
69 | Correct | 30 ms | 60244 KB | n=2000 |
70 | Correct | 29 ms | 60140 KB | n=2000 |
71 | Correct | 30 ms | 60232 KB | n=2000 |
72 | Correct | 28 ms | 60164 KB | n=2000 |
73 | Correct | 28 ms | 60244 KB | n=2000 |
74 | Correct | 27 ms | 55528 KB | n=1844 |
75 | Correct | 29 ms | 60244 KB | n=2000 |
76 | Correct | 31 ms | 60108 KB | n=2000 |
77 | Correct | 30 ms | 60128 KB | n=2000 |
78 | Correct | 34 ms | 60212 KB | n=2000 |
79 | Correct | 29 ms | 60108 KB | n=2000 |
80 | Correct | 30 ms | 60256 KB | n=2000 |
81 | Correct | 30 ms | 60264 KB | n=2000 |
82 | Correct | 29 ms | 60236 KB | n=2000 |
83 | Correct | 29 ms | 60236 KB | n=2000 |
84 | Correct | 30 ms | 60232 KB | n=2000 |
85 | Correct | 30 ms | 60244 KB | n=2000 |
86 | Correct | 31 ms | 60264 KB | n=2000 |
87 | Correct | 30 ms | 60216 KB | n=2000 |
88 | Correct | 32 ms | 60256 KB | n=2000 |
89 | Correct | 29 ms | 60244 KB | n=2000 |
90 | Correct | 32 ms | 60220 KB | n=2000 |
91 | Correct | 29 ms | 60120 KB | n=2000 |
92 | Runtime error | 110 ms | 262144 KB | Execution killed with signal 9 |
93 | Halted | 0 ms | 0 KB | - |