답안 #767845

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767845 2023-06-27T08:13:03 Z Dan4Life Vinjete (COI22_vinjete) C++17
100 / 100
503 ms 490704 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)1e5+10;
const int mxN2 = mxN*320;
int n, mx, IND = 1;
int seg[mxN2], lzy[mxN2];
vector<array<int,3>> adj[mxN];
int ans[mxN], ro[mxN], L[mxN2], R[mxN2];
 
int newParent(int l, int r){
	int p = ++IND; L[p]=l, R[p]=r; lzy[p]=-1;
	seg[p] = seg[L[p]]+seg[R[p]];
	return p;
}
 
int newlzyChild(int p, int v, int l, int r){
	int ind = ++IND;
	L[ind] = L[p]; R[ind] = R[p];
	lzy[ind] = v; seg[ind] = (r-l+1)*v;
	return ind;
}
 
void prop(int p, int l, int r){
	if(!p or l==r or lzy[p]==-1) return;
	int mid = (l+r)/2;
	if(!L[p]) L[p]=++IND;
	if(!R[p]) R[p]=++IND;
	L[p] = newlzyChild(L[p],lzy[p],l,mid);
	R[p] = newlzyChild(R[p],lzy[p],mid+1,r);
	lzy[p]=-1;
}
 
int upd(int i, int j, int v, int p, int l=1, int r=mx){
	if(i>r or j<l or i>j or !p) return p; prop(p,l,r);
	if(i<=l and r<=j) return newlzyChild(p,v,l,r);
	int mid = (l+r)/2;
	if(!L[p] and i<=mid) L[p]=++IND;
	if(!R[p] and j>mid) R[p]=++IND;
	return newParent(upd(i,j,v,L[p],l,mid),upd(i,j,v,R[p],mid+1,r));
}
 
void dfs(int s, int p){
	ans[s] = seg[ro[s]];
	for(auto [u,v,w] : adj[s])
		if(u!=p) ro[u] = upd(v,w,1,ro[s]), dfs(u,s);
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> mx; ro[1] = 1;
	memset(lzy,-1,sizeof(lzy));
	for(int i = 1; i < n; i++){
		int a, b, l, r; cin >> a >> b >> l >> r;
		adj[a].push_back({b,l,r}), adj[b].push_back({a,l,r});
	}
	dfs(1,0);
	for(int i = 2; i <= n; i++) cout << ans[i] << "\n";
}

Compilation message

Main.cpp: In function 'int upd(int, int, int, int, int, int)':
Main.cpp:34:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   34 |  if(i>r or j<l or i>j or !p) return p; prop(p,l,r);
      |  ^~
Main.cpp:34:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   34 |  if(i>r or j<l or i>j or !p) return p; prop(p,l,r);
      |                                        ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 128696 KB Output is correct
2 Correct 44 ms 128748 KB Output is correct
3 Correct 43 ms 128596 KB Output is correct
4 Correct 49 ms 128588 KB Output is correct
5 Correct 40 ms 128156 KB Output is correct
6 Correct 46 ms 128080 KB Output is correct
7 Correct 46 ms 127964 KB Output is correct
8 Correct 49 ms 127976 KB Output is correct
9 Correct 45 ms 128572 KB Output is correct
10 Correct 50 ms 128588 KB Output is correct
11 Correct 54 ms 128540 KB Output is correct
12 Correct 48 ms 128476 KB Output is correct
13 Correct 49 ms 128076 KB Output is correct
14 Correct 39 ms 128096 KB Output is correct
15 Correct 48 ms 127928 KB Output is correct
16 Correct 49 ms 127936 KB Output is correct
17 Correct 46 ms 128568 KB Output is correct
18 Correct 53 ms 128504 KB Output is correct
19 Correct 40 ms 128528 KB Output is correct
20 Correct 40 ms 128480 KB Output is correct
21 Correct 51 ms 128040 KB Output is correct
22 Correct 54 ms 128124 KB Output is correct
23 Correct 40 ms 127916 KB Output is correct
24 Correct 48 ms 127884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 128696 KB Output is correct
2 Correct 44 ms 128748 KB Output is correct
3 Correct 43 ms 128596 KB Output is correct
4 Correct 49 ms 128588 KB Output is correct
5 Correct 40 ms 128156 KB Output is correct
6 Correct 46 ms 128080 KB Output is correct
7 Correct 46 ms 127964 KB Output is correct
8 Correct 49 ms 127976 KB Output is correct
9 Correct 45 ms 128572 KB Output is correct
10 Correct 50 ms 128588 KB Output is correct
11 Correct 54 ms 128540 KB Output is correct
12 Correct 48 ms 128476 KB Output is correct
13 Correct 49 ms 128076 KB Output is correct
14 Correct 39 ms 128096 KB Output is correct
15 Correct 48 ms 127928 KB Output is correct
16 Correct 49 ms 127936 KB Output is correct
17 Correct 46 ms 128568 KB Output is correct
18 Correct 53 ms 128504 KB Output is correct
19 Correct 40 ms 128528 KB Output is correct
20 Correct 40 ms 128480 KB Output is correct
21 Correct 51 ms 128040 KB Output is correct
22 Correct 54 ms 128124 KB Output is correct
23 Correct 40 ms 127916 KB Output is correct
24 Correct 48 ms 127884 KB Output is correct
25 Correct 41 ms 130568 KB Output is correct
26 Correct 46 ms 130580 KB Output is correct
27 Correct 50 ms 131904 KB Output is correct
28 Correct 45 ms 131916 KB Output is correct
29 Correct 43 ms 128608 KB Output is correct
30 Correct 46 ms 128668 KB Output is correct
31 Correct 48 ms 129388 KB Output is correct
32 Correct 48 ms 129448 KB Output is correct
33 Correct 40 ms 129476 KB Output is correct
34 Correct 40 ms 129444 KB Output is correct
35 Correct 49 ms 130108 KB Output is correct
36 Correct 41 ms 130140 KB Output is correct
37 Correct 51 ms 131784 KB Output is correct
38 Correct 55 ms 131932 KB Output is correct
39 Correct 51 ms 128568 KB Output is correct
40 Correct 46 ms 128580 KB Output is correct
41 Correct 47 ms 129412 KB Output is correct
42 Correct 53 ms 129340 KB Output is correct
43 Correct 46 ms 129872 KB Output is correct
44 Correct 40 ms 130012 KB Output is correct
45 Correct 54 ms 131440 KB Output is correct
46 Correct 45 ms 131656 KB Output is correct
47 Correct 42 ms 128532 KB Output is correct
48 Correct 63 ms 128608 KB Output is correct
49 Correct 39 ms 129356 KB Output is correct
50 Correct 46 ms 129480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 128696 KB Output is correct
2 Correct 44 ms 128748 KB Output is correct
3 Correct 43 ms 128596 KB Output is correct
4 Correct 49 ms 128588 KB Output is correct
5 Correct 40 ms 128156 KB Output is correct
6 Correct 46 ms 128080 KB Output is correct
7 Correct 46 ms 127964 KB Output is correct
8 Correct 49 ms 127976 KB Output is correct
9 Correct 45 ms 128572 KB Output is correct
10 Correct 50 ms 128588 KB Output is correct
11 Correct 54 ms 128540 KB Output is correct
12 Correct 48 ms 128476 KB Output is correct
13 Correct 49 ms 128076 KB Output is correct
14 Correct 39 ms 128096 KB Output is correct
15 Correct 48 ms 127928 KB Output is correct
16 Correct 49 ms 127936 KB Output is correct
17 Correct 46 ms 128568 KB Output is correct
18 Correct 53 ms 128504 KB Output is correct
19 Correct 40 ms 128528 KB Output is correct
20 Correct 40 ms 128480 KB Output is correct
21 Correct 51 ms 128040 KB Output is correct
22 Correct 54 ms 128124 KB Output is correct
23 Correct 40 ms 127916 KB Output is correct
24 Correct 48 ms 127884 KB Output is correct
25 Correct 111 ms 180720 KB Output is correct
26 Correct 107 ms 180680 KB Output is correct
27 Correct 108 ms 179144 KB Output is correct
28 Correct 119 ms 179196 KB Output is correct
29 Correct 70 ms 141468 KB Output is correct
30 Correct 76 ms 141576 KB Output is correct
31 Correct 62 ms 130016 KB Output is correct
32 Correct 62 ms 130116 KB Output is correct
33 Correct 52 ms 130108 KB Output is correct
34 Correct 59 ms 130124 KB Output is correct
35 Correct 126 ms 171648 KB Output is correct
36 Correct 114 ms 171836 KB Output is correct
37 Correct 119 ms 177672 KB Output is correct
38 Correct 132 ms 177356 KB Output is correct
39 Correct 87 ms 139616 KB Output is correct
40 Correct 105 ms 139552 KB Output is correct
41 Correct 61 ms 129880 KB Output is correct
42 Correct 63 ms 129840 KB Output is correct
43 Correct 105 ms 168440 KB Output is correct
44 Correct 107 ms 168528 KB Output is correct
45 Correct 115 ms 172276 KB Output is correct
46 Correct 105 ms 171244 KB Output is correct
47 Correct 92 ms 138880 KB Output is correct
48 Correct 82 ms 139100 KB Output is correct
49 Correct 46 ms 130140 KB Output is correct
50 Correct 46 ms 129656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 128696 KB Output is correct
2 Correct 44 ms 128748 KB Output is correct
3 Correct 43 ms 128596 KB Output is correct
4 Correct 49 ms 128588 KB Output is correct
5 Correct 40 ms 128156 KB Output is correct
6 Correct 46 ms 128080 KB Output is correct
7 Correct 46 ms 127964 KB Output is correct
8 Correct 49 ms 127976 KB Output is correct
9 Correct 45 ms 128572 KB Output is correct
10 Correct 50 ms 128588 KB Output is correct
11 Correct 54 ms 128540 KB Output is correct
12 Correct 48 ms 128476 KB Output is correct
13 Correct 49 ms 128076 KB Output is correct
14 Correct 39 ms 128096 KB Output is correct
15 Correct 48 ms 127928 KB Output is correct
16 Correct 49 ms 127936 KB Output is correct
17 Correct 46 ms 128568 KB Output is correct
18 Correct 53 ms 128504 KB Output is correct
19 Correct 40 ms 128528 KB Output is correct
20 Correct 40 ms 128480 KB Output is correct
21 Correct 51 ms 128040 KB Output is correct
22 Correct 54 ms 128124 KB Output is correct
23 Correct 40 ms 127916 KB Output is correct
24 Correct 48 ms 127884 KB Output is correct
25 Correct 111 ms 180720 KB Output is correct
26 Correct 107 ms 180680 KB Output is correct
27 Correct 108 ms 179144 KB Output is correct
28 Correct 119 ms 179196 KB Output is correct
29 Correct 70 ms 141468 KB Output is correct
30 Correct 76 ms 141576 KB Output is correct
31 Correct 62 ms 130016 KB Output is correct
32 Correct 62 ms 130116 KB Output is correct
33 Correct 52 ms 130108 KB Output is correct
34 Correct 59 ms 130124 KB Output is correct
35 Correct 126 ms 171648 KB Output is correct
36 Correct 114 ms 171836 KB Output is correct
37 Correct 119 ms 177672 KB Output is correct
38 Correct 132 ms 177356 KB Output is correct
39 Correct 87 ms 139616 KB Output is correct
40 Correct 105 ms 139552 KB Output is correct
41 Correct 61 ms 129880 KB Output is correct
42 Correct 63 ms 129840 KB Output is correct
43 Correct 105 ms 168440 KB Output is correct
44 Correct 107 ms 168528 KB Output is correct
45 Correct 115 ms 172276 KB Output is correct
46 Correct 105 ms 171244 KB Output is correct
47 Correct 92 ms 138880 KB Output is correct
48 Correct 82 ms 139100 KB Output is correct
49 Correct 46 ms 130140 KB Output is correct
50 Correct 46 ms 129656 KB Output is correct
51 Correct 248 ms 271224 KB Output is correct
52 Correct 211 ms 271300 KB Output is correct
53 Correct 260 ms 269900 KB Output is correct
54 Correct 293 ms 269920 KB Output is correct
55 Correct 146 ms 163644 KB Output is correct
56 Correct 145 ms 163488 KB Output is correct
57 Correct 69 ms 136484 KB Output is correct
58 Correct 71 ms 136308 KB Output is correct
59 Correct 72 ms 136544 KB Output is correct
60 Correct 68 ms 136516 KB Output is correct
61 Correct 221 ms 246144 KB Output is correct
62 Correct 218 ms 246192 KB Output is correct
63 Correct 263 ms 264852 KB Output is correct
64 Correct 260 ms 264184 KB Output is correct
65 Correct 154 ms 159096 KB Output is correct
66 Correct 152 ms 158960 KB Output is correct
67 Correct 77 ms 135540 KB Output is correct
68 Correct 69 ms 135364 KB Output is correct
69 Correct 223 ms 237128 KB Output is correct
70 Correct 219 ms 237296 KB Output is correct
71 Correct 260 ms 253944 KB Output is correct
72 Correct 275 ms 252924 KB Output is correct
73 Correct 171 ms 157128 KB Output is correct
74 Correct 168 ms 156928 KB Output is correct
75 Correct 72 ms 135348 KB Output is correct
76 Correct 73 ms 136032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 128696 KB Output is correct
2 Correct 44 ms 128748 KB Output is correct
3 Correct 43 ms 128596 KB Output is correct
4 Correct 49 ms 128588 KB Output is correct
5 Correct 40 ms 128156 KB Output is correct
6 Correct 46 ms 128080 KB Output is correct
7 Correct 46 ms 127964 KB Output is correct
8 Correct 49 ms 127976 KB Output is correct
9 Correct 45 ms 128572 KB Output is correct
10 Correct 50 ms 128588 KB Output is correct
11 Correct 54 ms 128540 KB Output is correct
12 Correct 48 ms 128476 KB Output is correct
13 Correct 49 ms 128076 KB Output is correct
14 Correct 39 ms 128096 KB Output is correct
15 Correct 48 ms 127928 KB Output is correct
16 Correct 49 ms 127936 KB Output is correct
17 Correct 46 ms 128568 KB Output is correct
18 Correct 53 ms 128504 KB Output is correct
19 Correct 40 ms 128528 KB Output is correct
20 Correct 40 ms 128480 KB Output is correct
21 Correct 51 ms 128040 KB Output is correct
22 Correct 54 ms 128124 KB Output is correct
23 Correct 40 ms 127916 KB Output is correct
24 Correct 48 ms 127884 KB Output is correct
25 Correct 41 ms 130568 KB Output is correct
26 Correct 46 ms 130580 KB Output is correct
27 Correct 50 ms 131904 KB Output is correct
28 Correct 45 ms 131916 KB Output is correct
29 Correct 43 ms 128608 KB Output is correct
30 Correct 46 ms 128668 KB Output is correct
31 Correct 48 ms 129388 KB Output is correct
32 Correct 48 ms 129448 KB Output is correct
33 Correct 40 ms 129476 KB Output is correct
34 Correct 40 ms 129444 KB Output is correct
35 Correct 49 ms 130108 KB Output is correct
36 Correct 41 ms 130140 KB Output is correct
37 Correct 51 ms 131784 KB Output is correct
38 Correct 55 ms 131932 KB Output is correct
39 Correct 51 ms 128568 KB Output is correct
40 Correct 46 ms 128580 KB Output is correct
41 Correct 47 ms 129412 KB Output is correct
42 Correct 53 ms 129340 KB Output is correct
43 Correct 46 ms 129872 KB Output is correct
44 Correct 40 ms 130012 KB Output is correct
45 Correct 54 ms 131440 KB Output is correct
46 Correct 45 ms 131656 KB Output is correct
47 Correct 42 ms 128532 KB Output is correct
48 Correct 63 ms 128608 KB Output is correct
49 Correct 39 ms 129356 KB Output is correct
50 Correct 46 ms 129480 KB Output is correct
51 Correct 111 ms 180720 KB Output is correct
52 Correct 107 ms 180680 KB Output is correct
53 Correct 108 ms 179144 KB Output is correct
54 Correct 119 ms 179196 KB Output is correct
55 Correct 70 ms 141468 KB Output is correct
56 Correct 76 ms 141576 KB Output is correct
57 Correct 62 ms 130016 KB Output is correct
58 Correct 62 ms 130116 KB Output is correct
59 Correct 52 ms 130108 KB Output is correct
60 Correct 59 ms 130124 KB Output is correct
61 Correct 126 ms 171648 KB Output is correct
62 Correct 114 ms 171836 KB Output is correct
63 Correct 119 ms 177672 KB Output is correct
64 Correct 132 ms 177356 KB Output is correct
65 Correct 87 ms 139616 KB Output is correct
66 Correct 105 ms 139552 KB Output is correct
67 Correct 61 ms 129880 KB Output is correct
68 Correct 63 ms 129840 KB Output is correct
69 Correct 105 ms 168440 KB Output is correct
70 Correct 107 ms 168528 KB Output is correct
71 Correct 115 ms 172276 KB Output is correct
72 Correct 105 ms 171244 KB Output is correct
73 Correct 92 ms 138880 KB Output is correct
74 Correct 82 ms 139100 KB Output is correct
75 Correct 46 ms 130140 KB Output is correct
76 Correct 46 ms 129656 KB Output is correct
77 Correct 248 ms 271224 KB Output is correct
78 Correct 211 ms 271300 KB Output is correct
79 Correct 260 ms 269900 KB Output is correct
80 Correct 293 ms 269920 KB Output is correct
81 Correct 146 ms 163644 KB Output is correct
82 Correct 145 ms 163488 KB Output is correct
83 Correct 69 ms 136484 KB Output is correct
84 Correct 71 ms 136308 KB Output is correct
85 Correct 72 ms 136544 KB Output is correct
86 Correct 68 ms 136516 KB Output is correct
87 Correct 221 ms 246144 KB Output is correct
88 Correct 218 ms 246192 KB Output is correct
89 Correct 263 ms 264852 KB Output is correct
90 Correct 260 ms 264184 KB Output is correct
91 Correct 154 ms 159096 KB Output is correct
92 Correct 152 ms 158960 KB Output is correct
93 Correct 77 ms 135540 KB Output is correct
94 Correct 69 ms 135364 KB Output is correct
95 Correct 223 ms 237128 KB Output is correct
96 Correct 219 ms 237296 KB Output is correct
97 Correct 260 ms 253944 KB Output is correct
98 Correct 275 ms 252924 KB Output is correct
99 Correct 171 ms 157128 KB Output is correct
100 Correct 168 ms 156928 KB Output is correct
101 Correct 72 ms 135348 KB Output is correct
102 Correct 73 ms 136032 KB Output is correct
103 Correct 306 ms 396940 KB Output is correct
104 Correct 306 ms 396620 KB Output is correct
105 Correct 473 ms 485356 KB Output is correct
106 Correct 466 ms 486304 KB Output is correct
107 Correct 210 ms 194252 KB Output is correct
108 Correct 209 ms 194572 KB Output is correct
109 Correct 86 ms 153676 KB Output is correct
110 Correct 88 ms 153684 KB Output is correct
111 Correct 94 ms 153516 KB Output is correct
112 Correct 88 ms 153560 KB Output is correct
113 Correct 302 ms 350428 KB Output is correct
114 Correct 320 ms 350004 KB Output is correct
115 Correct 446 ms 490704 KB Output is correct
116 Correct 477 ms 489220 KB Output is correct
117 Correct 218 ms 190100 KB Output is correct
118 Correct 212 ms 190244 KB Output is correct
119 Correct 91 ms 153160 KB Output is correct
120 Correct 90 ms 152836 KB Output is correct
121 Correct 301 ms 331524 KB Output is correct
122 Correct 299 ms 331452 KB Output is correct
123 Correct 448 ms 471512 KB Output is correct
124 Correct 503 ms 478412 KB Output is correct
125 Correct 235 ms 187812 KB Output is correct
126 Correct 234 ms 188260 KB Output is correct
127 Correct 98 ms 154608 KB Output is correct
128 Correct 94 ms 153720 KB Output is correct