# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
334837 | 2020-12-10T05:04:43 Z | juggernaut | Birthday gift (IZhO18_treearray) | C++14 | 1319 ms | 83268 KB |
#include<bits/stdc++.h> using namespace std; int n,m,q,a[200005],up[200005][18],tin[200005],tout[200005],timer; vector<int>g[200005]; set<int>lc[200005],ar[200005]; set<int>::iterator it; void dfs(int v,int p){ tin[v]=++timer; up[v][0]=p; for(int i=1;i<18;i++)up[v][i]=up[up[v][i-1]][i-1]; for(int 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=17;i>=0;i--) if(!upper(up[a][i],b))a=up[a][i]; return up[a][0]; } int main(){ scanf("%d%d%d",&n,&m,&q); for(int i=1;i<n;i++){ int x,y; scanf("%d%d",&x,&y); g[x].push_back(y); g[y].push_back(x); } dfs(1,1); for(int i=1;i<=m;i++){ scanf("%d",&a[i]); ar[a[i]].insert(i); } for(int i=1;i<m;i++) lc[lca(a[i],a[i+1])].insert(i); while(q--){ int type; scanf("%d",&type); if(type&1){ int pos,val; scanf("%d%d",&pos,&val); ar[a[pos]].erase(pos); if(pos>1) lc[lca(a[pos],a[pos-1])].erase(pos-1); if(pos<m) lc[lca(a[pos],a[pos+1])].erase(pos); a[pos]=val; if(pos>1) lc[lca(a[pos],a[pos-1])].insert(pos-1); if(pos<m) lc[lca(a[pos],a[pos+1])].insert(pos); ar[a[pos]].insert(pos); }else{ int l,r,v,al=-1,arr=-1; scanf("%d%d%d",&l,&r,&v); //Case al=arr it=ar[v].lower_bound(l); if(it!=ar[v].end()) if(*it<=r)al=arr=*it; //Case al+1=arr it=lc[v].lower_bound(l); if(it!=lc[v].end()) if(*it<r)al=*it,arr=al+1; printf("%d %d\n",al,arr); } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 23788 KB | n=5 |
2 | Correct | 16 ms | 23788 KB | n=100 |
3 | Correct | 17 ms | 23788 KB | n=100 |
4 | Correct | 16 ms | 23788 KB | n=100 |
5 | Correct | 17 ms | 23788 KB | n=100 |
6 | Correct | 17 ms | 23788 KB | n=100 |
7 | Correct | 17 ms | 23788 KB | n=100 |
8 | Correct | 17 ms | 23788 KB | n=100 |
9 | Correct | 16 ms | 23788 KB | n=100 |
10 | Correct | 17 ms | 23788 KB | n=100 |
11 | Correct | 16 ms | 23788 KB | n=100 |
12 | Correct | 17 ms | 23788 KB | n=100 |
13 | Correct | 16 ms | 23900 KB | n=100 |
14 | Correct | 17 ms | 23788 KB | n=100 |
15 | Correct | 16 ms | 23788 KB | n=100 |
16 | Correct | 16 ms | 23788 KB | n=100 |
17 | Correct | 17 ms | 23788 KB | n=100 |
18 | Correct | 17 ms | 23788 KB | n=100 |
19 | Correct | 16 ms | 23788 KB | n=100 |
20 | Correct | 16 ms | 23788 KB | n=100 |
21 | Correct | 17 ms | 23788 KB | n=100 |
22 | Correct | 17 ms | 23788 KB | n=100 |
23 | Correct | 17 ms | 23916 KB | n=100 |
24 | Correct | 16 ms | 23936 KB | n=100 |
25 | Correct | 16 ms | 23788 KB | n=100 |
26 | Correct | 16 ms | 23788 KB | n=12 |
27 | Correct | 17 ms | 23788 KB | n=100 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 23788 KB | n=5 |
2 | Correct | 16 ms | 23788 KB | n=100 |
3 | Correct | 17 ms | 23788 KB | n=100 |
4 | Correct | 16 ms | 23788 KB | n=100 |
5 | Correct | 17 ms | 23788 KB | n=100 |
6 | Correct | 17 ms | 23788 KB | n=100 |
7 | Correct | 17 ms | 23788 KB | n=100 |
8 | Correct | 17 ms | 23788 KB | n=100 |
9 | Correct | 16 ms | 23788 KB | n=100 |
10 | Correct | 17 ms | 23788 KB | n=100 |
11 | Correct | 16 ms | 23788 KB | n=100 |
12 | Correct | 17 ms | 23788 KB | n=100 |
13 | Correct | 16 ms | 23900 KB | n=100 |
14 | Correct | 17 ms | 23788 KB | n=100 |
15 | Correct | 16 ms | 23788 KB | n=100 |
16 | Correct | 16 ms | 23788 KB | n=100 |
17 | Correct | 17 ms | 23788 KB | n=100 |
18 | Correct | 17 ms | 23788 KB | n=100 |
19 | Correct | 16 ms | 23788 KB | n=100 |
20 | Correct | 16 ms | 23788 KB | n=100 |
21 | Correct | 17 ms | 23788 KB | n=100 |
22 | Correct | 17 ms | 23788 KB | n=100 |
23 | Correct | 17 ms | 23916 KB | n=100 |
24 | Correct | 16 ms | 23936 KB | n=100 |
25 | Correct | 16 ms | 23788 KB | n=100 |
26 | Correct | 16 ms | 23788 KB | n=12 |
27 | Correct | 17 ms | 23788 KB | n=100 |
28 | Correct | 17 ms | 23916 KB | n=500 |
29 | Correct | 17 ms | 23916 KB | n=500 |
30 | Correct | 18 ms | 23916 KB | n=500 |
31 | Correct | 17 ms | 23916 KB | n=500 |
32 | Correct | 18 ms | 23916 KB | n=500 |
33 | Correct | 17 ms | 23916 KB | n=500 |
34 | Correct | 18 ms | 23916 KB | n=500 |
35 | Correct | 17 ms | 23916 KB | n=500 |
36 | Correct | 17 ms | 23916 KB | n=500 |
37 | Correct | 17 ms | 23916 KB | n=500 |
38 | Correct | 17 ms | 23916 KB | n=500 |
39 | Correct | 17 ms | 23916 KB | n=500 |
40 | Correct | 17 ms | 23916 KB | n=500 |
41 | Correct | 17 ms | 23916 KB | n=500 |
42 | Correct | 17 ms | 23916 KB | n=500 |
43 | Correct | 17 ms | 23916 KB | n=500 |
44 | Correct | 17 ms | 23916 KB | n=500 |
45 | Correct | 17 ms | 23916 KB | n=500 |
46 | Correct | 17 ms | 23916 KB | n=500 |
47 | Correct | 17 ms | 23916 KB | n=500 |
48 | Correct | 17 ms | 23916 KB | n=500 |
49 | Correct | 17 ms | 23916 KB | n=500 |
50 | Correct | 17 ms | 23916 KB | n=500 |
51 | Correct | 18 ms | 23916 KB | n=500 |
52 | Correct | 18 ms | 23916 KB | n=500 |
53 | Correct | 18 ms | 23916 KB | n=500 |
54 | Correct | 18 ms | 23916 KB | n=500 |
55 | Correct | 17 ms | 23916 KB | n=278 |
56 | Correct | 18 ms | 23916 KB | n=500 |
57 | Correct | 17 ms | 23916 KB | n=500 |
58 | Correct | 17 ms | 23916 KB | n=500 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 23788 KB | n=5 |
2 | Correct | 16 ms | 23788 KB | n=100 |
3 | Correct | 17 ms | 23788 KB | n=100 |
4 | Correct | 16 ms | 23788 KB | n=100 |
5 | Correct | 17 ms | 23788 KB | n=100 |
6 | Correct | 17 ms | 23788 KB | n=100 |
7 | Correct | 17 ms | 23788 KB | n=100 |
8 | Correct | 17 ms | 23788 KB | n=100 |
9 | Correct | 16 ms | 23788 KB | n=100 |
10 | Correct | 17 ms | 23788 KB | n=100 |
11 | Correct | 16 ms | 23788 KB | n=100 |
12 | Correct | 17 ms | 23788 KB | n=100 |
13 | Correct | 16 ms | 23900 KB | n=100 |
14 | Correct | 17 ms | 23788 KB | n=100 |
15 | Correct | 16 ms | 23788 KB | n=100 |
16 | Correct | 16 ms | 23788 KB | n=100 |
17 | Correct | 17 ms | 23788 KB | n=100 |
18 | Correct | 17 ms | 23788 KB | n=100 |
19 | Correct | 16 ms | 23788 KB | n=100 |
20 | Correct | 16 ms | 23788 KB | n=100 |
21 | Correct | 17 ms | 23788 KB | n=100 |
22 | Correct | 17 ms | 23788 KB | n=100 |
23 | Correct | 17 ms | 23916 KB | n=100 |
24 | Correct | 16 ms | 23936 KB | n=100 |
25 | Correct | 16 ms | 23788 KB | n=100 |
26 | Correct | 16 ms | 23788 KB | n=12 |
27 | Correct | 17 ms | 23788 KB | n=100 |
28 | Correct | 17 ms | 23916 KB | n=500 |
29 | Correct | 17 ms | 23916 KB | n=500 |
30 | Correct | 18 ms | 23916 KB | n=500 |
31 | Correct | 17 ms | 23916 KB | n=500 |
32 | Correct | 18 ms | 23916 KB | n=500 |
33 | Correct | 17 ms | 23916 KB | n=500 |
34 | Correct | 18 ms | 23916 KB | n=500 |
35 | Correct | 17 ms | 23916 KB | n=500 |
36 | Correct | 17 ms | 23916 KB | n=500 |
37 | Correct | 17 ms | 23916 KB | n=500 |
38 | Correct | 17 ms | 23916 KB | n=500 |
39 | Correct | 17 ms | 23916 KB | n=500 |
40 | Correct | 17 ms | 23916 KB | n=500 |
41 | Correct | 17 ms | 23916 KB | n=500 |
42 | Correct | 17 ms | 23916 KB | n=500 |
43 | Correct | 17 ms | 23916 KB | n=500 |
44 | Correct | 17 ms | 23916 KB | n=500 |
45 | Correct | 17 ms | 23916 KB | n=500 |
46 | Correct | 17 ms | 23916 KB | n=500 |
47 | Correct | 17 ms | 23916 KB | n=500 |
48 | Correct | 17 ms | 23916 KB | n=500 |
49 | Correct | 17 ms | 23916 KB | n=500 |
50 | Correct | 17 ms | 23916 KB | n=500 |
51 | Correct | 18 ms | 23916 KB | n=500 |
52 | Correct | 18 ms | 23916 KB | n=500 |
53 | Correct | 18 ms | 23916 KB | n=500 |
54 | Correct | 18 ms | 23916 KB | n=500 |
55 | Correct | 17 ms | 23916 KB | n=278 |
56 | Correct | 18 ms | 23916 KB | n=500 |
57 | Correct | 17 ms | 23916 KB | n=500 |
58 | Correct | 17 ms | 23916 KB | n=500 |
59 | Correct | 21 ms | 24300 KB | n=2000 |
60 | Correct | 20 ms | 24300 KB | n=2000 |
61 | Correct | 20 ms | 24300 KB | n=2000 |
62 | Correct | 21 ms | 24444 KB | n=2000 |
63 | Correct | 21 ms | 24300 KB | n=2000 |
64 | Correct | 20 ms | 24300 KB | n=2000 |
65 | Correct | 21 ms | 24300 KB | n=2000 |
66 | Correct | 20 ms | 24256 KB | n=2000 |
67 | Correct | 21 ms | 24300 KB | n=2000 |
68 | Correct | 20 ms | 24300 KB | n=2000 |
69 | Correct | 19 ms | 24300 KB | n=2000 |
70 | Correct | 19 ms | 24300 KB | n=2000 |
71 | Correct | 20 ms | 24300 KB | n=2000 |
72 | Correct | 21 ms | 24300 KB | n=2000 |
73 | Correct | 19 ms | 24300 KB | n=2000 |
74 | Correct | 20 ms | 24300 KB | n=1844 |
75 | Correct | 23 ms | 24300 KB | n=2000 |
76 | Correct | 21 ms | 24300 KB | n=2000 |
77 | Correct | 21 ms | 24300 KB | n=2000 |
78 | Correct | 21 ms | 24300 KB | n=2000 |
79 | Correct | 20 ms | 24300 KB | n=2000 |
80 | Correct | 19 ms | 24300 KB | n=2000 |
81 | Correct | 20 ms | 24300 KB | n=2000 |
82 | Correct | 20 ms | 24300 KB | n=2000 |
83 | Correct | 20 ms | 24300 KB | n=2000 |
84 | Correct | 21 ms | 24300 KB | n=2000 |
85 | Correct | 22 ms | 24300 KB | n=2000 |
86 | Correct | 21 ms | 24300 KB | n=2000 |
87 | Correct | 21 ms | 24300 KB | n=2000 |
88 | Correct | 19 ms | 24300 KB | n=2000 |
89 | Correct | 20 ms | 24444 KB | n=2000 |
90 | Correct | 21 ms | 24300 KB | n=2000 |
91 | Correct | 19 ms | 24300 KB | n=2000 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 23788 KB | n=5 |
2 | Correct | 16 ms | 23788 KB | n=100 |
3 | Correct | 17 ms | 23788 KB | n=100 |
4 | Correct | 16 ms | 23788 KB | n=100 |
5 | Correct | 17 ms | 23788 KB | n=100 |
6 | Correct | 17 ms | 23788 KB | n=100 |
7 | Correct | 17 ms | 23788 KB | n=100 |
8 | Correct | 17 ms | 23788 KB | n=100 |
9 | Correct | 16 ms | 23788 KB | n=100 |
10 | Correct | 17 ms | 23788 KB | n=100 |
11 | Correct | 16 ms | 23788 KB | n=100 |
12 | Correct | 17 ms | 23788 KB | n=100 |
13 | Correct | 16 ms | 23900 KB | n=100 |
14 | Correct | 17 ms | 23788 KB | n=100 |
15 | Correct | 16 ms | 23788 KB | n=100 |
16 | Correct | 16 ms | 23788 KB | n=100 |
17 | Correct | 17 ms | 23788 KB | n=100 |
18 | Correct | 17 ms | 23788 KB | n=100 |
19 | Correct | 16 ms | 23788 KB | n=100 |
20 | Correct | 16 ms | 23788 KB | n=100 |
21 | Correct | 17 ms | 23788 KB | n=100 |
22 | Correct | 17 ms | 23788 KB | n=100 |
23 | Correct | 17 ms | 23916 KB | n=100 |
24 | Correct | 16 ms | 23936 KB | n=100 |
25 | Correct | 16 ms | 23788 KB | n=100 |
26 | Correct | 16 ms | 23788 KB | n=12 |
27 | Correct | 17 ms | 23788 KB | n=100 |
28 | Correct | 17 ms | 23916 KB | n=500 |
29 | Correct | 17 ms | 23916 KB | n=500 |
30 | Correct | 18 ms | 23916 KB | n=500 |
31 | Correct | 17 ms | 23916 KB | n=500 |
32 | Correct | 18 ms | 23916 KB | n=500 |
33 | Correct | 17 ms | 23916 KB | n=500 |
34 | Correct | 18 ms | 23916 KB | n=500 |
35 | Correct | 17 ms | 23916 KB | n=500 |
36 | Correct | 17 ms | 23916 KB | n=500 |
37 | Correct | 17 ms | 23916 KB | n=500 |
38 | Correct | 17 ms | 23916 KB | n=500 |
39 | Correct | 17 ms | 23916 KB | n=500 |
40 | Correct | 17 ms | 23916 KB | n=500 |
41 | Correct | 17 ms | 23916 KB | n=500 |
42 | Correct | 17 ms | 23916 KB | n=500 |
43 | Correct | 17 ms | 23916 KB | n=500 |
44 | Correct | 17 ms | 23916 KB | n=500 |
45 | Correct | 17 ms | 23916 KB | n=500 |
46 | Correct | 17 ms | 23916 KB | n=500 |
47 | Correct | 17 ms | 23916 KB | n=500 |
48 | Correct | 17 ms | 23916 KB | n=500 |
49 | Correct | 17 ms | 23916 KB | n=500 |
50 | Correct | 17 ms | 23916 KB | n=500 |
51 | Correct | 18 ms | 23916 KB | n=500 |
52 | Correct | 18 ms | 23916 KB | n=500 |
53 | Correct | 18 ms | 23916 KB | n=500 |
54 | Correct | 18 ms | 23916 KB | n=500 |
55 | Correct | 17 ms | 23916 KB | n=278 |
56 | Correct | 18 ms | 23916 KB | n=500 |
57 | Correct | 17 ms | 23916 KB | n=500 |
58 | Correct | 17 ms | 23916 KB | n=500 |
59 | Correct | 21 ms | 24300 KB | n=2000 |
60 | Correct | 20 ms | 24300 KB | n=2000 |
61 | Correct | 20 ms | 24300 KB | n=2000 |
62 | Correct | 21 ms | 24444 KB | n=2000 |
63 | Correct | 21 ms | 24300 KB | n=2000 |
64 | Correct | 20 ms | 24300 KB | n=2000 |
65 | Correct | 21 ms | 24300 KB | n=2000 |
66 | Correct | 20 ms | 24256 KB | n=2000 |
67 | Correct | 21 ms | 24300 KB | n=2000 |
68 | Correct | 20 ms | 24300 KB | n=2000 |
69 | Correct | 19 ms | 24300 KB | n=2000 |
70 | Correct | 19 ms | 24300 KB | n=2000 |
71 | Correct | 20 ms | 24300 KB | n=2000 |
72 | Correct | 21 ms | 24300 KB | n=2000 |
73 | Correct | 19 ms | 24300 KB | n=2000 |
74 | Correct | 20 ms | 24300 KB | n=1844 |
75 | Correct | 23 ms | 24300 KB | n=2000 |
76 | Correct | 21 ms | 24300 KB | n=2000 |
77 | Correct | 21 ms | 24300 KB | n=2000 |
78 | Correct | 21 ms | 24300 KB | n=2000 |
79 | Correct | 20 ms | 24300 KB | n=2000 |
80 | Correct | 19 ms | 24300 KB | n=2000 |
81 | Correct | 20 ms | 24300 KB | n=2000 |
82 | Correct | 20 ms | 24300 KB | n=2000 |
83 | Correct | 20 ms | 24300 KB | n=2000 |
84 | Correct | 21 ms | 24300 KB | n=2000 |
85 | Correct | 22 ms | 24300 KB | n=2000 |
86 | Correct | 21 ms | 24300 KB | n=2000 |
87 | Correct | 21 ms | 24300 KB | n=2000 |
88 | Correct | 19 ms | 24300 KB | n=2000 |
89 | Correct | 20 ms | 24444 KB | n=2000 |
90 | Correct | 21 ms | 24300 KB | n=2000 |
91 | Correct | 19 ms | 24300 KB | n=2000 |
92 | Correct | 889 ms | 73688 KB | n=200000 |
93 | Correct | 984 ms | 78740 KB | n=200000 |
94 | Correct | 744 ms | 82156 KB | n=200000 |
95 | Correct | 871 ms | 73768 KB | n=200000 |
96 | Correct | 875 ms | 73720 KB | n=200000 |
97 | Correct | 1082 ms | 77848 KB | n=200000 |
98 | Correct | 870 ms | 73628 KB | n=200000 |
99 | Correct | 1043 ms | 73888 KB | n=200000 |
100 | Correct | 878 ms | 73828 KB | n=200000 |
101 | Correct | 684 ms | 83268 KB | n=200000 |
102 | Correct | 540 ms | 74860 KB | n=200000 |
103 | Correct | 547 ms | 74988 KB | n=200000 |
104 | Correct | 546 ms | 74836 KB | n=200000 |
105 | Correct | 547 ms | 75256 KB | n=200000 |
106 | Correct | 557 ms | 75244 KB | n=200000 |
107 | Correct | 547 ms | 75408 KB | n=200000 |
108 | Correct | 955 ms | 73708 KB | n=200000 |
109 | Correct | 943 ms | 73756 KB | n=200000 |
110 | Correct | 945 ms | 73836 KB | n=200000 |
111 | Correct | 934 ms | 73152 KB | n=200000 |
112 | Correct | 728 ms | 82348 KB | n=200000 |
113 | Correct | 1054 ms | 77816 KB | n=200000 |
114 | Correct | 964 ms | 73192 KB | n=200000 |
115 | Correct | 1319 ms | 75736 KB | n=200000 |
116 | Correct | 821 ms | 73868 KB | n=200000 |
117 | Correct | 687 ms | 82704 KB | n=200000 |
118 | Correct | 1150 ms | 76612 KB | n=200000 |
119 | Correct | 844 ms | 73824 KB | n=200000 |
120 | Correct | 621 ms | 82216 KB | n=200000 |
121 | Correct | 636 ms | 82188 KB | n=200000 |
122 | Correct | 660 ms | 82612 KB | n=200000 |
123 | Correct | 560 ms | 75116 KB | n=200000 |
124 | Correct | 228 ms | 38636 KB | n=25264 |