# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
334910 | 2020-12-10T08:37:56 Z | beksultan04 | Birthday gift (IZhO18_treearray) | C++14 | 4000 ms | 84344 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define pb push_back #define endi puts(""); const int N = 2e5+12,INF=1e9+7; int q[N],up[N][40],tin[N],tout[N],cnt; vector <int> g[N]; void dfs(int x,int p){ int i; tin[x]=++cnt; up[x][0]=p; for (i=1;i<20;++i) up[x][i]= up[up[x][i-1]][i-1]; for (i=0;i<g[x].size();++i){ if (g[x][i] != p){ dfs(g[x][i],x); } } tout[x] = ++cnt; } bool upper(int a,int b){ ret (tin[a] <= tin[b] && tout[a] >= tout[b]); } int lca(int a,int b){ int i; if (upper(a,b))ret a; if (upper(b,a))ret b; for(i=19;i>=0;--i){ if (!upper(up[a][i],b)){ a = up[a][i]; } } ret up[a][0]; } main(){ int n,m,t,i,j; scan3(n,m,t) for (i=1;i<n;++i){ int x,y; scan2(x,y) g[x].pb(y); g[y].pb(x); } dfs(1,1); for (i=1;i<=m;++i) scan1(q[i]) while (t--){ int type; scan1(type) if (type==1){ int l,r; scan2(l,r) q[l]=r; } else { int l,r,v,ll=-1,rr=-1; scan3(l,r,v) for (i=l;i<r;++i){ int lc = lca(q[i],q[i+1]); if (lc == v){ ll=i; rr=i+1; break; } if (q[i] == v){ ll=i; rr=i; break; } } if (q[r] == v)ll=r,rr=r; cout <<ll<<" "<<rr<<"\n"; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5100 KB | n=5 |
2 | Correct | 4 ms | 5100 KB | n=100 |
3 | Correct | 4 ms | 5120 KB | n=100 |
4 | Correct | 4 ms | 5100 KB | n=100 |
5 | Correct | 4 ms | 5100 KB | n=100 |
6 | Correct | 4 ms | 5100 KB | n=100 |
7 | Correct | 4 ms | 5100 KB | n=100 |
8 | Correct | 4 ms | 5100 KB | n=100 |
9 | Correct | 4 ms | 5100 KB | n=100 |
10 | Correct | 4 ms | 5100 KB | n=100 |
11 | Correct | 4 ms | 5120 KB | n=100 |
12 | Correct | 4 ms | 5112 KB | n=100 |
13 | Correct | 4 ms | 5100 KB | n=100 |
14 | Correct | 4 ms | 5100 KB | n=100 |
15 | Correct | 4 ms | 5120 KB | n=100 |
16 | Correct | 4 ms | 5100 KB | n=100 |
17 | Correct | 4 ms | 5100 KB | n=100 |
18 | Correct | 4 ms | 5100 KB | n=100 |
19 | Correct | 4 ms | 5100 KB | n=100 |
20 | Correct | 4 ms | 5100 KB | n=100 |
21 | Correct | 4 ms | 5100 KB | n=100 |
22 | Correct | 4 ms | 5100 KB | n=100 |
23 | Correct | 4 ms | 5112 KB | n=100 |
24 | Correct | 4 ms | 5100 KB | n=100 |
25 | Correct | 4 ms | 5100 KB | n=100 |
26 | Correct | 4 ms | 5100 KB | n=12 |
27 | Correct | 4 ms | 5100 KB | n=100 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5100 KB | n=5 |
2 | Correct | 4 ms | 5100 KB | n=100 |
3 | Correct | 4 ms | 5120 KB | n=100 |
4 | Correct | 4 ms | 5100 KB | n=100 |
5 | Correct | 4 ms | 5100 KB | n=100 |
6 | Correct | 4 ms | 5100 KB | n=100 |
7 | Correct | 4 ms | 5100 KB | n=100 |
8 | Correct | 4 ms | 5100 KB | n=100 |
9 | Correct | 4 ms | 5100 KB | n=100 |
10 | Correct | 4 ms | 5100 KB | n=100 |
11 | Correct | 4 ms | 5120 KB | n=100 |
12 | Correct | 4 ms | 5112 KB | n=100 |
13 | Correct | 4 ms | 5100 KB | n=100 |
14 | Correct | 4 ms | 5100 KB | n=100 |
15 | Correct | 4 ms | 5120 KB | n=100 |
16 | Correct | 4 ms | 5100 KB | n=100 |
17 | Correct | 4 ms | 5100 KB | n=100 |
18 | Correct | 4 ms | 5100 KB | n=100 |
19 | Correct | 4 ms | 5100 KB | n=100 |
20 | Correct | 4 ms | 5100 KB | n=100 |
21 | Correct | 4 ms | 5100 KB | n=100 |
22 | Correct | 4 ms | 5100 KB | n=100 |
23 | Correct | 4 ms | 5112 KB | n=100 |
24 | Correct | 4 ms | 5100 KB | n=100 |
25 | Correct | 4 ms | 5100 KB | n=100 |
26 | Correct | 4 ms | 5100 KB | n=12 |
27 | Correct | 4 ms | 5100 KB | n=100 |
28 | Correct | 5 ms | 5228 KB | n=500 |
29 | Correct | 4 ms | 5228 KB | n=500 |
30 | Correct | 5 ms | 5228 KB | n=500 |
31 | Correct | 5 ms | 5248 KB | n=500 |
32 | Correct | 4 ms | 5228 KB | n=500 |
33 | Correct | 6 ms | 5228 KB | n=500 |
34 | Correct | 5 ms | 5228 KB | n=500 |
35 | Correct | 5 ms | 5228 KB | n=500 |
36 | Correct | 20 ms | 5228 KB | n=500 |
37 | Correct | 25 ms | 5228 KB | n=500 |
38 | Correct | 20 ms | 5356 KB | n=500 |
39 | Correct | 12 ms | 5228 KB | n=500 |
40 | Correct | 12 ms | 5228 KB | n=500 |
41 | Correct | 12 ms | 5228 KB | n=500 |
42 | Correct | 12 ms | 5228 KB | n=500 |
43 | Correct | 12 ms | 5228 KB | n=500 |
44 | Correct | 12 ms | 5228 KB | n=500 |
45 | Correct | 5 ms | 5228 KB | n=500 |
46 | Correct | 4 ms | 5228 KB | n=500 |
47 | Correct | 4 ms | 5228 KB | n=500 |
48 | Correct | 4 ms | 5228 KB | n=500 |
49 | Correct | 4 ms | 5228 KB | n=500 |
50 | Correct | 8 ms | 5228 KB | n=500 |
51 | Correct | 6 ms | 5228 KB | n=500 |
52 | Correct | 4 ms | 5228 KB | n=500 |
53 | Correct | 7 ms | 5228 KB | n=500 |
54 | Correct | 5 ms | 5228 KB | n=500 |
55 | Correct | 4 ms | 5100 KB | n=278 |
56 | Correct | 5 ms | 5228 KB | n=500 |
57 | Correct | 5 ms | 5228 KB | n=500 |
58 | Correct | 16 ms | 5228 KB | n=500 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5100 KB | n=5 |
2 | Correct | 4 ms | 5100 KB | n=100 |
3 | Correct | 4 ms | 5120 KB | n=100 |
4 | Correct | 4 ms | 5100 KB | n=100 |
5 | Correct | 4 ms | 5100 KB | n=100 |
6 | Correct | 4 ms | 5100 KB | n=100 |
7 | Correct | 4 ms | 5100 KB | n=100 |
8 | Correct | 4 ms | 5100 KB | n=100 |
9 | Correct | 4 ms | 5100 KB | n=100 |
10 | Correct | 4 ms | 5100 KB | n=100 |
11 | Correct | 4 ms | 5120 KB | n=100 |
12 | Correct | 4 ms | 5112 KB | n=100 |
13 | Correct | 4 ms | 5100 KB | n=100 |
14 | Correct | 4 ms | 5100 KB | n=100 |
15 | Correct | 4 ms | 5120 KB | n=100 |
16 | Correct | 4 ms | 5100 KB | n=100 |
17 | Correct | 4 ms | 5100 KB | n=100 |
18 | Correct | 4 ms | 5100 KB | n=100 |
19 | Correct | 4 ms | 5100 KB | n=100 |
20 | Correct | 4 ms | 5100 KB | n=100 |
21 | Correct | 4 ms | 5100 KB | n=100 |
22 | Correct | 4 ms | 5100 KB | n=100 |
23 | Correct | 4 ms | 5112 KB | n=100 |
24 | Correct | 4 ms | 5100 KB | n=100 |
25 | Correct | 4 ms | 5100 KB | n=100 |
26 | Correct | 4 ms | 5100 KB | n=12 |
27 | Correct | 4 ms | 5100 KB | n=100 |
28 | Correct | 5 ms | 5228 KB | n=500 |
29 | Correct | 4 ms | 5228 KB | n=500 |
30 | Correct | 5 ms | 5228 KB | n=500 |
31 | Correct | 5 ms | 5248 KB | n=500 |
32 | Correct | 4 ms | 5228 KB | n=500 |
33 | Correct | 6 ms | 5228 KB | n=500 |
34 | Correct | 5 ms | 5228 KB | n=500 |
35 | Correct | 5 ms | 5228 KB | n=500 |
36 | Correct | 20 ms | 5228 KB | n=500 |
37 | Correct | 25 ms | 5228 KB | n=500 |
38 | Correct | 20 ms | 5356 KB | n=500 |
39 | Correct | 12 ms | 5228 KB | n=500 |
40 | Correct | 12 ms | 5228 KB | n=500 |
41 | Correct | 12 ms | 5228 KB | n=500 |
42 | Correct | 12 ms | 5228 KB | n=500 |
43 | Correct | 12 ms | 5228 KB | n=500 |
44 | Correct | 12 ms | 5228 KB | n=500 |
45 | Correct | 5 ms | 5228 KB | n=500 |
46 | Correct | 4 ms | 5228 KB | n=500 |
47 | Correct | 4 ms | 5228 KB | n=500 |
48 | Correct | 4 ms | 5228 KB | n=500 |
49 | Correct | 4 ms | 5228 KB | n=500 |
50 | Correct | 8 ms | 5228 KB | n=500 |
51 | Correct | 6 ms | 5228 KB | n=500 |
52 | Correct | 4 ms | 5228 KB | n=500 |
53 | Correct | 7 ms | 5228 KB | n=500 |
54 | Correct | 5 ms | 5228 KB | n=500 |
55 | Correct | 4 ms | 5100 KB | n=278 |
56 | Correct | 5 ms | 5228 KB | n=500 |
57 | Correct | 5 ms | 5228 KB | n=500 |
58 | Correct | 16 ms | 5228 KB | n=500 |
59 | Correct | 7 ms | 5868 KB | n=2000 |
60 | Correct | 10 ms | 6016 KB | n=2000 |
61 | Correct | 23 ms | 5868 KB | n=2000 |
62 | Correct | 27 ms | 5996 KB | n=2000 |
63 | Correct | 8 ms | 5868 KB | n=2000 |
64 | Correct | 29 ms | 5868 KB | n=2000 |
65 | Correct | 7 ms | 5868 KB | n=2000 |
66 | Correct | 18 ms | 5868 KB | n=2000 |
67 | Correct | 9 ms | 5868 KB | n=2000 |
68 | Correct | 25 ms | 5868 KB | n=2000 |
69 | Correct | 263 ms | 6124 KB | n=2000 |
70 | Correct | 264 ms | 6004 KB | n=2000 |
71 | Correct | 258 ms | 5996 KB | n=2000 |
72 | Correct | 135 ms | 5936 KB | n=2000 |
73 | Correct | 135 ms | 5868 KB | n=2000 |
74 | Correct | 8 ms | 5740 KB | n=1844 |
75 | Correct | 136 ms | 5868 KB | n=2000 |
76 | Correct | 133 ms | 5868 KB | n=2000 |
77 | Correct | 135 ms | 5868 KB | n=2000 |
78 | Correct | 143 ms | 5868 KB | n=2000 |
79 | Correct | 6 ms | 5868 KB | n=2000 |
80 | Correct | 13 ms | 5868 KB | n=2000 |
81 | Correct | 24 ms | 5868 KB | n=2000 |
82 | Correct | 6 ms | 5868 KB | n=2000 |
83 | Correct | 17 ms | 5868 KB | n=2000 |
84 | Correct | 73 ms | 5868 KB | n=2000 |
85 | Correct | 50 ms | 5868 KB | n=2000 |
86 | Correct | 59 ms | 5868 KB | n=2000 |
87 | Correct | 80 ms | 5996 KB | n=2000 |
88 | Correct | 22 ms | 5868 KB | n=2000 |
89 | Correct | 22 ms | 5868 KB | n=2000 |
90 | Correct | 14 ms | 5868 KB | n=2000 |
91 | Correct | 201 ms | 5868 KB | n=2000 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5100 KB | n=5 |
2 | Correct | 4 ms | 5100 KB | n=100 |
3 | Correct | 4 ms | 5120 KB | n=100 |
4 | Correct | 4 ms | 5100 KB | n=100 |
5 | Correct | 4 ms | 5100 KB | n=100 |
6 | Correct | 4 ms | 5100 KB | n=100 |
7 | Correct | 4 ms | 5100 KB | n=100 |
8 | Correct | 4 ms | 5100 KB | n=100 |
9 | Correct | 4 ms | 5100 KB | n=100 |
10 | Correct | 4 ms | 5100 KB | n=100 |
11 | Correct | 4 ms | 5120 KB | n=100 |
12 | Correct | 4 ms | 5112 KB | n=100 |
13 | Correct | 4 ms | 5100 KB | n=100 |
14 | Correct | 4 ms | 5100 KB | n=100 |
15 | Correct | 4 ms | 5120 KB | n=100 |
16 | Correct | 4 ms | 5100 KB | n=100 |
17 | Correct | 4 ms | 5100 KB | n=100 |
18 | Correct | 4 ms | 5100 KB | n=100 |
19 | Correct | 4 ms | 5100 KB | n=100 |
20 | Correct | 4 ms | 5100 KB | n=100 |
21 | Correct | 4 ms | 5100 KB | n=100 |
22 | Correct | 4 ms | 5100 KB | n=100 |
23 | Correct | 4 ms | 5112 KB | n=100 |
24 | Correct | 4 ms | 5100 KB | n=100 |
25 | Correct | 4 ms | 5100 KB | n=100 |
26 | Correct | 4 ms | 5100 KB | n=12 |
27 | Correct | 4 ms | 5100 KB | n=100 |
28 | Correct | 5 ms | 5228 KB | n=500 |
29 | Correct | 4 ms | 5228 KB | n=500 |
30 | Correct | 5 ms | 5228 KB | n=500 |
31 | Correct | 5 ms | 5248 KB | n=500 |
32 | Correct | 4 ms | 5228 KB | n=500 |
33 | Correct | 6 ms | 5228 KB | n=500 |
34 | Correct | 5 ms | 5228 KB | n=500 |
35 | Correct | 5 ms | 5228 KB | n=500 |
36 | Correct | 20 ms | 5228 KB | n=500 |
37 | Correct | 25 ms | 5228 KB | n=500 |
38 | Correct | 20 ms | 5356 KB | n=500 |
39 | Correct | 12 ms | 5228 KB | n=500 |
40 | Correct | 12 ms | 5228 KB | n=500 |
41 | Correct | 12 ms | 5228 KB | n=500 |
42 | Correct | 12 ms | 5228 KB | n=500 |
43 | Correct | 12 ms | 5228 KB | n=500 |
44 | Correct | 12 ms | 5228 KB | n=500 |
45 | Correct | 5 ms | 5228 KB | n=500 |
46 | Correct | 4 ms | 5228 KB | n=500 |
47 | Correct | 4 ms | 5228 KB | n=500 |
48 | Correct | 4 ms | 5228 KB | n=500 |
49 | Correct | 4 ms | 5228 KB | n=500 |
50 | Correct | 8 ms | 5228 KB | n=500 |
51 | Correct | 6 ms | 5228 KB | n=500 |
52 | Correct | 4 ms | 5228 KB | n=500 |
53 | Correct | 7 ms | 5228 KB | n=500 |
54 | Correct | 5 ms | 5228 KB | n=500 |
55 | Correct | 4 ms | 5100 KB | n=278 |
56 | Correct | 5 ms | 5228 KB | n=500 |
57 | Correct | 5 ms | 5228 KB | n=500 |
58 | Correct | 16 ms | 5228 KB | n=500 |
59 | Correct | 7 ms | 5868 KB | n=2000 |
60 | Correct | 10 ms | 6016 KB | n=2000 |
61 | Correct | 23 ms | 5868 KB | n=2000 |
62 | Correct | 27 ms | 5996 KB | n=2000 |
63 | Correct | 8 ms | 5868 KB | n=2000 |
64 | Correct | 29 ms | 5868 KB | n=2000 |
65 | Correct | 7 ms | 5868 KB | n=2000 |
66 | Correct | 18 ms | 5868 KB | n=2000 |
67 | Correct | 9 ms | 5868 KB | n=2000 |
68 | Correct | 25 ms | 5868 KB | n=2000 |
69 | Correct | 263 ms | 6124 KB | n=2000 |
70 | Correct | 264 ms | 6004 KB | n=2000 |
71 | Correct | 258 ms | 5996 KB | n=2000 |
72 | Correct | 135 ms | 5936 KB | n=2000 |
73 | Correct | 135 ms | 5868 KB | n=2000 |
74 | Correct | 8 ms | 5740 KB | n=1844 |
75 | Correct | 136 ms | 5868 KB | n=2000 |
76 | Correct | 133 ms | 5868 KB | n=2000 |
77 | Correct | 135 ms | 5868 KB | n=2000 |
78 | Correct | 143 ms | 5868 KB | n=2000 |
79 | Correct | 6 ms | 5868 KB | n=2000 |
80 | Correct | 13 ms | 5868 KB | n=2000 |
81 | Correct | 24 ms | 5868 KB | n=2000 |
82 | Correct | 6 ms | 5868 KB | n=2000 |
83 | Correct | 17 ms | 5868 KB | n=2000 |
84 | Correct | 73 ms | 5868 KB | n=2000 |
85 | Correct | 50 ms | 5868 KB | n=2000 |
86 | Correct | 59 ms | 5868 KB | n=2000 |
87 | Correct | 80 ms | 5996 KB | n=2000 |
88 | Correct | 22 ms | 5868 KB | n=2000 |
89 | Correct | 22 ms | 5868 KB | n=2000 |
90 | Correct | 14 ms | 5868 KB | n=2000 |
91 | Correct | 201 ms | 5868 KB | n=2000 |
92 | Correct | 979 ms | 81596 KB | n=200000 |
93 | Execution timed out | 4043 ms | 84344 KB | Time limit exceeded |
94 | Halted | 0 ms | 0 KB | - |