Submission #767843

# Submission time Handle Problem Language Result Execution time Memory
767843 2023-06-27T08:11:04 Z Dan4Life Vinjete (COI22_vinjete) C++17
69 / 100
960 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)1e5+10;
const int mxN2 = mxN*240;
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 34 ms 97452 KB Output is correct
2 Correct 33 ms 97444 KB Output is correct
3 Correct 34 ms 97356 KB Output is correct
4 Correct 38 ms 97224 KB Output is correct
5 Correct 36 ms 96884 KB Output is correct
6 Correct 38 ms 96864 KB Output is correct
7 Correct 33 ms 96596 KB Output is correct
8 Correct 34 ms 96572 KB Output is correct
9 Correct 34 ms 97280 KB Output is correct
10 Correct 34 ms 97228 KB Output is correct
11 Correct 35 ms 97240 KB Output is correct
12 Correct 37 ms 97284 KB Output is correct
13 Correct 39 ms 96844 KB Output is correct
14 Correct 39 ms 96824 KB Output is correct
15 Correct 34 ms 96580 KB Output is correct
16 Correct 41 ms 96616 KB Output is correct
17 Correct 35 ms 97256 KB Output is correct
18 Correct 34 ms 97216 KB Output is correct
19 Correct 36 ms 97168 KB Output is correct
20 Correct 35 ms 97084 KB Output is correct
21 Correct 35 ms 96828 KB Output is correct
22 Correct 34 ms 96728 KB Output is correct
23 Correct 34 ms 96576 KB Output is correct
24 Correct 36 ms 96612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 97452 KB Output is correct
2 Correct 33 ms 97444 KB Output is correct
3 Correct 34 ms 97356 KB Output is correct
4 Correct 38 ms 97224 KB Output is correct
5 Correct 36 ms 96884 KB Output is correct
6 Correct 38 ms 96864 KB Output is correct
7 Correct 33 ms 96596 KB Output is correct
8 Correct 34 ms 96572 KB Output is correct
9 Correct 34 ms 97280 KB Output is correct
10 Correct 34 ms 97228 KB Output is correct
11 Correct 35 ms 97240 KB Output is correct
12 Correct 37 ms 97284 KB Output is correct
13 Correct 39 ms 96844 KB Output is correct
14 Correct 39 ms 96824 KB Output is correct
15 Correct 34 ms 96580 KB Output is correct
16 Correct 41 ms 96616 KB Output is correct
17 Correct 35 ms 97256 KB Output is correct
18 Correct 34 ms 97216 KB Output is correct
19 Correct 36 ms 97168 KB Output is correct
20 Correct 35 ms 97084 KB Output is correct
21 Correct 35 ms 96828 KB Output is correct
22 Correct 34 ms 96728 KB Output is correct
23 Correct 34 ms 96576 KB Output is correct
24 Correct 36 ms 96612 KB Output is correct
25 Correct 40 ms 99324 KB Output is correct
26 Correct 37 ms 99276 KB Output is correct
27 Correct 41 ms 100612 KB Output is correct
28 Correct 39 ms 100564 KB Output is correct
29 Correct 38 ms 97260 KB Output is correct
30 Correct 43 ms 97324 KB Output is correct
31 Correct 37 ms 98124 KB Output is correct
32 Correct 35 ms 98032 KB Output is correct
33 Correct 44 ms 98056 KB Output is correct
34 Correct 36 ms 98088 KB Output is correct
35 Correct 38 ms 98740 KB Output is correct
36 Correct 42 ms 98792 KB Output is correct
37 Correct 45 ms 100544 KB Output is correct
38 Correct 38 ms 100560 KB Output is correct
39 Correct 36 ms 97212 KB Output is correct
40 Correct 36 ms 97324 KB Output is correct
41 Correct 37 ms 98088 KB Output is correct
42 Correct 38 ms 98048 KB Output is correct
43 Correct 37 ms 98572 KB Output is correct
44 Correct 40 ms 98636 KB Output is correct
45 Correct 45 ms 100052 KB Output is correct
46 Correct 37 ms 100304 KB Output is correct
47 Correct 37 ms 97216 KB Output is correct
48 Correct 42 ms 97268 KB Output is correct
49 Correct 39 ms 98140 KB Output is correct
50 Correct 37 ms 98124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 97452 KB Output is correct
2 Correct 33 ms 97444 KB Output is correct
3 Correct 34 ms 97356 KB Output is correct
4 Correct 38 ms 97224 KB Output is correct
5 Correct 36 ms 96884 KB Output is correct
6 Correct 38 ms 96864 KB Output is correct
7 Correct 33 ms 96596 KB Output is correct
8 Correct 34 ms 96572 KB Output is correct
9 Correct 34 ms 97280 KB Output is correct
10 Correct 34 ms 97228 KB Output is correct
11 Correct 35 ms 97240 KB Output is correct
12 Correct 37 ms 97284 KB Output is correct
13 Correct 39 ms 96844 KB Output is correct
14 Correct 39 ms 96824 KB Output is correct
15 Correct 34 ms 96580 KB Output is correct
16 Correct 41 ms 96616 KB Output is correct
17 Correct 35 ms 97256 KB Output is correct
18 Correct 34 ms 97216 KB Output is correct
19 Correct 36 ms 97168 KB Output is correct
20 Correct 35 ms 97084 KB Output is correct
21 Correct 35 ms 96828 KB Output is correct
22 Correct 34 ms 96728 KB Output is correct
23 Correct 34 ms 96576 KB Output is correct
24 Correct 36 ms 96612 KB Output is correct
25 Correct 95 ms 149368 KB Output is correct
26 Correct 96 ms 149548 KB Output is correct
27 Correct 97 ms 148080 KB Output is correct
28 Correct 101 ms 147940 KB Output is correct
29 Correct 66 ms 110268 KB Output is correct
30 Correct 65 ms 110188 KB Output is correct
31 Correct 42 ms 98740 KB Output is correct
32 Correct 39 ms 98792 KB Output is correct
33 Correct 39 ms 98868 KB Output is correct
34 Correct 40 ms 98804 KB Output is correct
35 Correct 102 ms 140540 KB Output is correct
36 Correct 90 ms 140432 KB Output is correct
37 Correct 101 ms 146444 KB Output is correct
38 Correct 98 ms 146020 KB Output is correct
39 Correct 78 ms 108300 KB Output is correct
40 Correct 84 ms 108228 KB Output is correct
41 Correct 40 ms 98536 KB Output is correct
42 Correct 40 ms 98412 KB Output is correct
43 Correct 102 ms 137112 KB Output is correct
44 Correct 89 ms 137204 KB Output is correct
45 Correct 100 ms 140980 KB Output is correct
46 Correct 100 ms 139900 KB Output is correct
47 Correct 81 ms 107588 KB Output is correct
48 Correct 72 ms 107708 KB Output is correct
49 Correct 46 ms 98752 KB Output is correct
50 Correct 42 ms 98328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 97452 KB Output is correct
2 Correct 33 ms 97444 KB Output is correct
3 Correct 34 ms 97356 KB Output is correct
4 Correct 38 ms 97224 KB Output is correct
5 Correct 36 ms 96884 KB Output is correct
6 Correct 38 ms 96864 KB Output is correct
7 Correct 33 ms 96596 KB Output is correct
8 Correct 34 ms 96572 KB Output is correct
9 Correct 34 ms 97280 KB Output is correct
10 Correct 34 ms 97228 KB Output is correct
11 Correct 35 ms 97240 KB Output is correct
12 Correct 37 ms 97284 KB Output is correct
13 Correct 39 ms 96844 KB Output is correct
14 Correct 39 ms 96824 KB Output is correct
15 Correct 34 ms 96580 KB Output is correct
16 Correct 41 ms 96616 KB Output is correct
17 Correct 35 ms 97256 KB Output is correct
18 Correct 34 ms 97216 KB Output is correct
19 Correct 36 ms 97168 KB Output is correct
20 Correct 35 ms 97084 KB Output is correct
21 Correct 35 ms 96828 KB Output is correct
22 Correct 34 ms 96728 KB Output is correct
23 Correct 34 ms 96576 KB Output is correct
24 Correct 36 ms 96612 KB Output is correct
25 Correct 95 ms 149368 KB Output is correct
26 Correct 96 ms 149548 KB Output is correct
27 Correct 97 ms 148080 KB Output is correct
28 Correct 101 ms 147940 KB Output is correct
29 Correct 66 ms 110268 KB Output is correct
30 Correct 65 ms 110188 KB Output is correct
31 Correct 42 ms 98740 KB Output is correct
32 Correct 39 ms 98792 KB Output is correct
33 Correct 39 ms 98868 KB Output is correct
34 Correct 40 ms 98804 KB Output is correct
35 Correct 102 ms 140540 KB Output is correct
36 Correct 90 ms 140432 KB Output is correct
37 Correct 101 ms 146444 KB Output is correct
38 Correct 98 ms 146020 KB Output is correct
39 Correct 78 ms 108300 KB Output is correct
40 Correct 84 ms 108228 KB Output is correct
41 Correct 40 ms 98536 KB Output is correct
42 Correct 40 ms 98412 KB Output is correct
43 Correct 102 ms 137112 KB Output is correct
44 Correct 89 ms 137204 KB Output is correct
45 Correct 100 ms 140980 KB Output is correct
46 Correct 100 ms 139900 KB Output is correct
47 Correct 81 ms 107588 KB Output is correct
48 Correct 72 ms 107708 KB Output is correct
49 Correct 46 ms 98752 KB Output is correct
50 Correct 42 ms 98328 KB Output is correct
51 Correct 187 ms 240080 KB Output is correct
52 Correct 168 ms 240168 KB Output is correct
53 Correct 209 ms 238924 KB Output is correct
54 Correct 213 ms 238784 KB Output is correct
55 Correct 128 ms 132336 KB Output is correct
56 Correct 120 ms 132424 KB Output is correct
57 Correct 62 ms 105116 KB Output is correct
58 Correct 51 ms 105036 KB Output is correct
59 Correct 52 ms 105220 KB Output is correct
60 Correct 51 ms 105164 KB Output is correct
61 Correct 184 ms 214828 KB Output is correct
62 Correct 187 ms 214880 KB Output is correct
63 Correct 219 ms 233568 KB Output is correct
64 Correct 223 ms 233284 KB Output is correct
65 Correct 146 ms 128324 KB Output is correct
66 Correct 131 ms 127724 KB Output is correct
67 Correct 52 ms 104184 KB Output is correct
68 Correct 52 ms 104056 KB Output is correct
69 Correct 182 ms 206172 KB Output is correct
70 Correct 197 ms 206176 KB Output is correct
71 Correct 216 ms 222628 KB Output is correct
72 Correct 240 ms 222076 KB Output is correct
73 Correct 139 ms 126124 KB Output is correct
74 Correct 149 ms 126032 KB Output is correct
75 Correct 53 ms 103956 KB Output is correct
76 Correct 56 ms 104716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 97452 KB Output is correct
2 Correct 33 ms 97444 KB Output is correct
3 Correct 34 ms 97356 KB Output is correct
4 Correct 38 ms 97224 KB Output is correct
5 Correct 36 ms 96884 KB Output is correct
6 Correct 38 ms 96864 KB Output is correct
7 Correct 33 ms 96596 KB Output is correct
8 Correct 34 ms 96572 KB Output is correct
9 Correct 34 ms 97280 KB Output is correct
10 Correct 34 ms 97228 KB Output is correct
11 Correct 35 ms 97240 KB Output is correct
12 Correct 37 ms 97284 KB Output is correct
13 Correct 39 ms 96844 KB Output is correct
14 Correct 39 ms 96824 KB Output is correct
15 Correct 34 ms 96580 KB Output is correct
16 Correct 41 ms 96616 KB Output is correct
17 Correct 35 ms 97256 KB Output is correct
18 Correct 34 ms 97216 KB Output is correct
19 Correct 36 ms 97168 KB Output is correct
20 Correct 35 ms 97084 KB Output is correct
21 Correct 35 ms 96828 KB Output is correct
22 Correct 34 ms 96728 KB Output is correct
23 Correct 34 ms 96576 KB Output is correct
24 Correct 36 ms 96612 KB Output is correct
25 Correct 40 ms 99324 KB Output is correct
26 Correct 37 ms 99276 KB Output is correct
27 Correct 41 ms 100612 KB Output is correct
28 Correct 39 ms 100564 KB Output is correct
29 Correct 38 ms 97260 KB Output is correct
30 Correct 43 ms 97324 KB Output is correct
31 Correct 37 ms 98124 KB Output is correct
32 Correct 35 ms 98032 KB Output is correct
33 Correct 44 ms 98056 KB Output is correct
34 Correct 36 ms 98088 KB Output is correct
35 Correct 38 ms 98740 KB Output is correct
36 Correct 42 ms 98792 KB Output is correct
37 Correct 45 ms 100544 KB Output is correct
38 Correct 38 ms 100560 KB Output is correct
39 Correct 36 ms 97212 KB Output is correct
40 Correct 36 ms 97324 KB Output is correct
41 Correct 37 ms 98088 KB Output is correct
42 Correct 38 ms 98048 KB Output is correct
43 Correct 37 ms 98572 KB Output is correct
44 Correct 40 ms 98636 KB Output is correct
45 Correct 45 ms 100052 KB Output is correct
46 Correct 37 ms 100304 KB Output is correct
47 Correct 37 ms 97216 KB Output is correct
48 Correct 42 ms 97268 KB Output is correct
49 Correct 39 ms 98140 KB Output is correct
50 Correct 37 ms 98124 KB Output is correct
51 Correct 95 ms 149368 KB Output is correct
52 Correct 96 ms 149548 KB Output is correct
53 Correct 97 ms 148080 KB Output is correct
54 Correct 101 ms 147940 KB Output is correct
55 Correct 66 ms 110268 KB Output is correct
56 Correct 65 ms 110188 KB Output is correct
57 Correct 42 ms 98740 KB Output is correct
58 Correct 39 ms 98792 KB Output is correct
59 Correct 39 ms 98868 KB Output is correct
60 Correct 40 ms 98804 KB Output is correct
61 Correct 102 ms 140540 KB Output is correct
62 Correct 90 ms 140432 KB Output is correct
63 Correct 101 ms 146444 KB Output is correct
64 Correct 98 ms 146020 KB Output is correct
65 Correct 78 ms 108300 KB Output is correct
66 Correct 84 ms 108228 KB Output is correct
67 Correct 40 ms 98536 KB Output is correct
68 Correct 40 ms 98412 KB Output is correct
69 Correct 102 ms 137112 KB Output is correct
70 Correct 89 ms 137204 KB Output is correct
71 Correct 100 ms 140980 KB Output is correct
72 Correct 100 ms 139900 KB Output is correct
73 Correct 81 ms 107588 KB Output is correct
74 Correct 72 ms 107708 KB Output is correct
75 Correct 46 ms 98752 KB Output is correct
76 Correct 42 ms 98328 KB Output is correct
77 Correct 187 ms 240080 KB Output is correct
78 Correct 168 ms 240168 KB Output is correct
79 Correct 209 ms 238924 KB Output is correct
80 Correct 213 ms 238784 KB Output is correct
81 Correct 128 ms 132336 KB Output is correct
82 Correct 120 ms 132424 KB Output is correct
83 Correct 62 ms 105116 KB Output is correct
84 Correct 51 ms 105036 KB Output is correct
85 Correct 52 ms 105220 KB Output is correct
86 Correct 51 ms 105164 KB Output is correct
87 Correct 184 ms 214828 KB Output is correct
88 Correct 187 ms 214880 KB Output is correct
89 Correct 219 ms 233568 KB Output is correct
90 Correct 223 ms 233284 KB Output is correct
91 Correct 146 ms 128324 KB Output is correct
92 Correct 131 ms 127724 KB Output is correct
93 Correct 52 ms 104184 KB Output is correct
94 Correct 52 ms 104056 KB Output is correct
95 Correct 182 ms 206172 KB Output is correct
96 Correct 197 ms 206176 KB Output is correct
97 Correct 216 ms 222628 KB Output is correct
98 Correct 240 ms 222076 KB Output is correct
99 Correct 139 ms 126124 KB Output is correct
100 Correct 149 ms 126032 KB Output is correct
101 Correct 53 ms 103956 KB Output is correct
102 Correct 56 ms 104716 KB Output is correct
103 Correct 276 ms 365848 KB Output is correct
104 Correct 269 ms 365940 KB Output is correct
105 Runtime error 960 ms 524288 KB Execution killed with signal 11
106 Halted 0 ms 0 KB -