Submission #767237

# Submission time Handle Problem Language Result Execution time Memory
767237 2023-06-26T14:26:58 Z Dan4Life Vinjete (COI22_vinjete) C++17
100 / 100
551 ms 520840 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)1e5+10;
const int mxN2 = mxN*400;
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);
      |                                        ^~~~
# Verdict Execution time Memory Grader output
1 Correct 51 ms 160060 KB Output is correct
2 Correct 52 ms 160032 KB Output is correct
3 Correct 57 ms 159948 KB Output is correct
4 Correct 61 ms 159948 KB Output is correct
5 Correct 52 ms 159432 KB Output is correct
6 Correct 52 ms 159428 KB Output is correct
7 Correct 53 ms 159252 KB Output is correct
8 Correct 52 ms 159176 KB Output is correct
9 Correct 53 ms 159948 KB Output is correct
10 Correct 54 ms 159848 KB Output is correct
11 Correct 53 ms 159920 KB Output is correct
12 Correct 52 ms 159820 KB Output is correct
13 Correct 57 ms 159436 KB Output is correct
14 Correct 56 ms 159476 KB Output is correct
15 Correct 52 ms 159160 KB Output is correct
16 Correct 56 ms 159216 KB Output is correct
17 Correct 53 ms 159820 KB Output is correct
18 Correct 51 ms 159852 KB Output is correct
19 Correct 63 ms 159692 KB Output is correct
20 Correct 52 ms 159760 KB Output is correct
21 Correct 50 ms 159336 KB Output is correct
22 Correct 53 ms 159376 KB Output is correct
23 Correct 57 ms 159200 KB Output is correct
24 Correct 53 ms 159196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 160060 KB Output is correct
2 Correct 52 ms 160032 KB Output is correct
3 Correct 57 ms 159948 KB Output is correct
4 Correct 61 ms 159948 KB Output is correct
5 Correct 52 ms 159432 KB Output is correct
6 Correct 52 ms 159428 KB Output is correct
7 Correct 53 ms 159252 KB Output is correct
8 Correct 52 ms 159176 KB Output is correct
9 Correct 53 ms 159948 KB Output is correct
10 Correct 54 ms 159848 KB Output is correct
11 Correct 53 ms 159920 KB Output is correct
12 Correct 52 ms 159820 KB Output is correct
13 Correct 57 ms 159436 KB Output is correct
14 Correct 56 ms 159476 KB Output is correct
15 Correct 52 ms 159160 KB Output is correct
16 Correct 56 ms 159216 KB Output is correct
17 Correct 53 ms 159820 KB Output is correct
18 Correct 51 ms 159852 KB Output is correct
19 Correct 63 ms 159692 KB Output is correct
20 Correct 52 ms 159760 KB Output is correct
21 Correct 50 ms 159336 KB Output is correct
22 Correct 53 ms 159376 KB Output is correct
23 Correct 57 ms 159200 KB Output is correct
24 Correct 53 ms 159196 KB Output is correct
25 Correct 54 ms 161864 KB Output is correct
26 Correct 53 ms 161824 KB Output is correct
27 Correct 56 ms 163132 KB Output is correct
28 Correct 55 ms 163248 KB Output is correct
29 Correct 53 ms 159948 KB Output is correct
30 Correct 54 ms 159868 KB Output is correct
31 Correct 54 ms 160684 KB Output is correct
32 Correct 55 ms 160748 KB Output is correct
33 Correct 55 ms 160708 KB Output is correct
34 Correct 56 ms 160756 KB Output is correct
35 Correct 54 ms 161448 KB Output is correct
36 Correct 53 ms 161400 KB Output is correct
37 Correct 57 ms 163132 KB Output is correct
38 Correct 57 ms 163148 KB Output is correct
39 Correct 54 ms 159880 KB Output is correct
40 Correct 55 ms 159896 KB Output is correct
41 Correct 63 ms 160740 KB Output is correct
42 Correct 55 ms 160716 KB Output is correct
43 Correct 54 ms 161176 KB Output is correct
44 Correct 55 ms 161296 KB Output is correct
45 Correct 57 ms 162668 KB Output is correct
46 Correct 56 ms 162960 KB Output is correct
47 Correct 54 ms 159844 KB Output is correct
48 Correct 55 ms 159820 KB Output is correct
49 Correct 55 ms 160716 KB Output is correct
50 Correct 55 ms 160716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 160060 KB Output is correct
2 Correct 52 ms 160032 KB Output is correct
3 Correct 57 ms 159948 KB Output is correct
4 Correct 61 ms 159948 KB Output is correct
5 Correct 52 ms 159432 KB Output is correct
6 Correct 52 ms 159428 KB Output is correct
7 Correct 53 ms 159252 KB Output is correct
8 Correct 52 ms 159176 KB Output is correct
9 Correct 53 ms 159948 KB Output is correct
10 Correct 54 ms 159848 KB Output is correct
11 Correct 53 ms 159920 KB Output is correct
12 Correct 52 ms 159820 KB Output is correct
13 Correct 57 ms 159436 KB Output is correct
14 Correct 56 ms 159476 KB Output is correct
15 Correct 52 ms 159160 KB Output is correct
16 Correct 56 ms 159216 KB Output is correct
17 Correct 53 ms 159820 KB Output is correct
18 Correct 51 ms 159852 KB Output is correct
19 Correct 63 ms 159692 KB Output is correct
20 Correct 52 ms 159760 KB Output is correct
21 Correct 50 ms 159336 KB Output is correct
22 Correct 53 ms 159376 KB Output is correct
23 Correct 57 ms 159200 KB Output is correct
24 Correct 53 ms 159196 KB Output is correct
25 Correct 130 ms 211900 KB Output is correct
26 Correct 120 ms 211944 KB Output is correct
27 Correct 114 ms 210340 KB Output is correct
28 Correct 115 ms 210192 KB Output is correct
29 Correct 85 ms 172512 KB Output is correct
30 Correct 84 ms 172492 KB Output is correct
31 Correct 59 ms 161364 KB Output is correct
32 Correct 74 ms 161360 KB Output is correct
33 Correct 60 ms 161284 KB Output is correct
34 Correct 60 ms 161280 KB Output is correct
35 Correct 109 ms 202656 KB Output is correct
36 Correct 134 ms 202868 KB Output is correct
37 Correct 119 ms 208660 KB Output is correct
38 Correct 117 ms 208268 KB Output is correct
39 Correct 86 ms 170652 KB Output is correct
40 Correct 92 ms 170640 KB Output is correct
41 Correct 62 ms 161112 KB Output is correct
42 Correct 60 ms 161092 KB Output is correct
43 Correct 107 ms 199316 KB Output is correct
44 Correct 144 ms 199512 KB Output is correct
45 Correct 126 ms 203176 KB Output is correct
46 Correct 119 ms 202288 KB Output is correct
47 Correct 91 ms 169772 KB Output is correct
48 Correct 94 ms 169948 KB Output is correct
49 Correct 61 ms 161432 KB Output is correct
50 Correct 61 ms 160936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 160060 KB Output is correct
2 Correct 52 ms 160032 KB Output is correct
3 Correct 57 ms 159948 KB Output is correct
4 Correct 61 ms 159948 KB Output is correct
5 Correct 52 ms 159432 KB Output is correct
6 Correct 52 ms 159428 KB Output is correct
7 Correct 53 ms 159252 KB Output is correct
8 Correct 52 ms 159176 KB Output is correct
9 Correct 53 ms 159948 KB Output is correct
10 Correct 54 ms 159848 KB Output is correct
11 Correct 53 ms 159920 KB Output is correct
12 Correct 52 ms 159820 KB Output is correct
13 Correct 57 ms 159436 KB Output is correct
14 Correct 56 ms 159476 KB Output is correct
15 Correct 52 ms 159160 KB Output is correct
16 Correct 56 ms 159216 KB Output is correct
17 Correct 53 ms 159820 KB Output is correct
18 Correct 51 ms 159852 KB Output is correct
19 Correct 63 ms 159692 KB Output is correct
20 Correct 52 ms 159760 KB Output is correct
21 Correct 50 ms 159336 KB Output is correct
22 Correct 53 ms 159376 KB Output is correct
23 Correct 57 ms 159200 KB Output is correct
24 Correct 53 ms 159196 KB Output is correct
25 Correct 130 ms 211900 KB Output is correct
26 Correct 120 ms 211944 KB Output is correct
27 Correct 114 ms 210340 KB Output is correct
28 Correct 115 ms 210192 KB Output is correct
29 Correct 85 ms 172512 KB Output is correct
30 Correct 84 ms 172492 KB Output is correct
31 Correct 59 ms 161364 KB Output is correct
32 Correct 74 ms 161360 KB Output is correct
33 Correct 60 ms 161284 KB Output is correct
34 Correct 60 ms 161280 KB Output is correct
35 Correct 109 ms 202656 KB Output is correct
36 Correct 134 ms 202868 KB Output is correct
37 Correct 119 ms 208660 KB Output is correct
38 Correct 117 ms 208268 KB Output is correct
39 Correct 86 ms 170652 KB Output is correct
40 Correct 92 ms 170640 KB Output is correct
41 Correct 62 ms 161112 KB Output is correct
42 Correct 60 ms 161092 KB Output is correct
43 Correct 107 ms 199316 KB Output is correct
44 Correct 144 ms 199512 KB Output is correct
45 Correct 126 ms 203176 KB Output is correct
46 Correct 119 ms 202288 KB Output is correct
47 Correct 91 ms 169772 KB Output is correct
48 Correct 94 ms 169948 KB Output is correct
49 Correct 61 ms 161432 KB Output is correct
50 Correct 61 ms 160936 KB Output is correct
51 Correct 242 ms 302036 KB Output is correct
52 Correct 235 ms 301924 KB Output is correct
53 Correct 242 ms 300616 KB Output is correct
54 Correct 239 ms 300616 KB Output is correct
55 Correct 153 ms 194176 KB Output is correct
56 Correct 151 ms 194108 KB Output is correct
57 Correct 77 ms 167500 KB Output is correct
58 Correct 77 ms 167500 KB Output is correct
59 Correct 77 ms 167500 KB Output is correct
60 Correct 77 ms 167528 KB Output is correct
61 Correct 217 ms 276812 KB Output is correct
62 Correct 213 ms 276948 KB Output is correct
63 Correct 267 ms 295704 KB Output is correct
64 Correct 270 ms 294888 KB Output is correct
65 Correct 154 ms 189784 KB Output is correct
66 Correct 159 ms 189636 KB Output is correct
67 Correct 84 ms 166704 KB Output is correct
68 Correct 79 ms 166640 KB Output is correct
69 Correct 205 ms 267804 KB Output is correct
70 Correct 223 ms 268016 KB Output is correct
71 Correct 250 ms 284512 KB Output is correct
72 Correct 253 ms 283620 KB Output is correct
73 Correct 173 ms 187720 KB Output is correct
74 Correct 165 ms 187588 KB Output is correct
75 Correct 80 ms 166400 KB Output is correct
76 Correct 79 ms 167184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 160060 KB Output is correct
2 Correct 52 ms 160032 KB Output is correct
3 Correct 57 ms 159948 KB Output is correct
4 Correct 61 ms 159948 KB Output is correct
5 Correct 52 ms 159432 KB Output is correct
6 Correct 52 ms 159428 KB Output is correct
7 Correct 53 ms 159252 KB Output is correct
8 Correct 52 ms 159176 KB Output is correct
9 Correct 53 ms 159948 KB Output is correct
10 Correct 54 ms 159848 KB Output is correct
11 Correct 53 ms 159920 KB Output is correct
12 Correct 52 ms 159820 KB Output is correct
13 Correct 57 ms 159436 KB Output is correct
14 Correct 56 ms 159476 KB Output is correct
15 Correct 52 ms 159160 KB Output is correct
16 Correct 56 ms 159216 KB Output is correct
17 Correct 53 ms 159820 KB Output is correct
18 Correct 51 ms 159852 KB Output is correct
19 Correct 63 ms 159692 KB Output is correct
20 Correct 52 ms 159760 KB Output is correct
21 Correct 50 ms 159336 KB Output is correct
22 Correct 53 ms 159376 KB Output is correct
23 Correct 57 ms 159200 KB Output is correct
24 Correct 53 ms 159196 KB Output is correct
25 Correct 54 ms 161864 KB Output is correct
26 Correct 53 ms 161824 KB Output is correct
27 Correct 56 ms 163132 KB Output is correct
28 Correct 55 ms 163248 KB Output is correct
29 Correct 53 ms 159948 KB Output is correct
30 Correct 54 ms 159868 KB Output is correct
31 Correct 54 ms 160684 KB Output is correct
32 Correct 55 ms 160748 KB Output is correct
33 Correct 55 ms 160708 KB Output is correct
34 Correct 56 ms 160756 KB Output is correct
35 Correct 54 ms 161448 KB Output is correct
36 Correct 53 ms 161400 KB Output is correct
37 Correct 57 ms 163132 KB Output is correct
38 Correct 57 ms 163148 KB Output is correct
39 Correct 54 ms 159880 KB Output is correct
40 Correct 55 ms 159896 KB Output is correct
41 Correct 63 ms 160740 KB Output is correct
42 Correct 55 ms 160716 KB Output is correct
43 Correct 54 ms 161176 KB Output is correct
44 Correct 55 ms 161296 KB Output is correct
45 Correct 57 ms 162668 KB Output is correct
46 Correct 56 ms 162960 KB Output is correct
47 Correct 54 ms 159844 KB Output is correct
48 Correct 55 ms 159820 KB Output is correct
49 Correct 55 ms 160716 KB Output is correct
50 Correct 55 ms 160716 KB Output is correct
51 Correct 130 ms 211900 KB Output is correct
52 Correct 120 ms 211944 KB Output is correct
53 Correct 114 ms 210340 KB Output is correct
54 Correct 115 ms 210192 KB Output is correct
55 Correct 85 ms 172512 KB Output is correct
56 Correct 84 ms 172492 KB Output is correct
57 Correct 59 ms 161364 KB Output is correct
58 Correct 74 ms 161360 KB Output is correct
59 Correct 60 ms 161284 KB Output is correct
60 Correct 60 ms 161280 KB Output is correct
61 Correct 109 ms 202656 KB Output is correct
62 Correct 134 ms 202868 KB Output is correct
63 Correct 119 ms 208660 KB Output is correct
64 Correct 117 ms 208268 KB Output is correct
65 Correct 86 ms 170652 KB Output is correct
66 Correct 92 ms 170640 KB Output is correct
67 Correct 62 ms 161112 KB Output is correct
68 Correct 60 ms 161092 KB Output is correct
69 Correct 107 ms 199316 KB Output is correct
70 Correct 144 ms 199512 KB Output is correct
71 Correct 126 ms 203176 KB Output is correct
72 Correct 119 ms 202288 KB Output is correct
73 Correct 91 ms 169772 KB Output is correct
74 Correct 94 ms 169948 KB Output is correct
75 Correct 61 ms 161432 KB Output is correct
76 Correct 61 ms 160936 KB Output is correct
77 Correct 242 ms 302036 KB Output is correct
78 Correct 235 ms 301924 KB Output is correct
79 Correct 242 ms 300616 KB Output is correct
80 Correct 239 ms 300616 KB Output is correct
81 Correct 153 ms 194176 KB Output is correct
82 Correct 151 ms 194108 KB Output is correct
83 Correct 77 ms 167500 KB Output is correct
84 Correct 77 ms 167500 KB Output is correct
85 Correct 77 ms 167500 KB Output is correct
86 Correct 77 ms 167528 KB Output is correct
87 Correct 217 ms 276812 KB Output is correct
88 Correct 213 ms 276948 KB Output is correct
89 Correct 267 ms 295704 KB Output is correct
90 Correct 270 ms 294888 KB Output is correct
91 Correct 154 ms 189784 KB Output is correct
92 Correct 159 ms 189636 KB Output is correct
93 Correct 84 ms 166704 KB Output is correct
94 Correct 79 ms 166640 KB Output is correct
95 Correct 205 ms 267804 KB Output is correct
96 Correct 223 ms 268016 KB Output is correct
97 Correct 250 ms 284512 KB Output is correct
98 Correct 253 ms 283620 KB Output is correct
99 Correct 173 ms 187720 KB Output is correct
100 Correct 165 ms 187588 KB Output is correct
101 Correct 80 ms 166400 KB Output is correct
102 Correct 79 ms 167184 KB Output is correct
103 Correct 370 ms 427784 KB Output is correct
104 Correct 312 ms 427704 KB Output is correct
105 Correct 551 ms 516572 KB Output is correct
106 Correct 470 ms 516328 KB Output is correct
107 Correct 214 ms 224864 KB Output is correct
108 Correct 211 ms 224780 KB Output is correct
109 Correct 103 ms 184740 KB Output is correct
110 Correct 104 ms 184736 KB Output is correct
111 Correct 99 ms 184704 KB Output is correct
112 Correct 99 ms 184652 KB Output is correct
113 Correct 306 ms 381100 KB Output is correct
114 Correct 308 ms 380948 KB Output is correct
115 Correct 491 ms 520840 KB Output is correct
116 Correct 455 ms 519128 KB Output is correct
117 Correct 229 ms 220116 KB Output is correct
118 Correct 213 ms 220620 KB Output is correct
119 Correct 101 ms 184264 KB Output is correct
120 Correct 98 ms 184040 KB Output is correct
121 Correct 338 ms 361800 KB Output is correct
122 Correct 287 ms 361796 KB Output is correct
123 Correct 438 ms 501788 KB Output is correct
124 Correct 430 ms 508496 KB Output is correct
125 Correct 249 ms 217956 KB Output is correct
126 Correct 221 ms 218688 KB Output is correct
127 Correct 100 ms 185676 KB Output is correct
128 Correct 102 ms 184844 KB Output is correct