Submission #767844

# Submission time Handle Problem Language Result Execution time Memory
767844 2023-06-27T08:12:50 Z Dan4Life Vinjete (COI22_vinjete) C++17
69 / 100
970 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)1e5+10;
const int mxN2 = mxN*300;
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 42 ms 120920 KB Output is correct
2 Correct 42 ms 120908 KB Output is correct
3 Correct 47 ms 120756 KB Output is correct
4 Correct 42 ms 120780 KB Output is correct
5 Correct 42 ms 120320 KB Output is correct
6 Correct 42 ms 120268 KB Output is correct
7 Correct 43 ms 120144 KB Output is correct
8 Correct 41 ms 120076 KB Output is correct
9 Correct 42 ms 120704 KB Output is correct
10 Correct 42 ms 120716 KB Output is correct
11 Correct 48 ms 120752 KB Output is correct
12 Correct 43 ms 120652 KB Output is correct
13 Correct 43 ms 120256 KB Output is correct
14 Correct 45 ms 120352 KB Output is correct
15 Correct 43 ms 120136 KB Output is correct
16 Correct 42 ms 120028 KB Output is correct
17 Correct 42 ms 120744 KB Output is correct
18 Correct 43 ms 120684 KB Output is correct
19 Correct 43 ms 120576 KB Output is correct
20 Correct 43 ms 120696 KB Output is correct
21 Correct 43 ms 120272 KB Output is correct
22 Correct 43 ms 120296 KB Output is correct
23 Correct 42 ms 120064 KB Output is correct
24 Correct 43 ms 120088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 120920 KB Output is correct
2 Correct 42 ms 120908 KB Output is correct
3 Correct 47 ms 120756 KB Output is correct
4 Correct 42 ms 120780 KB Output is correct
5 Correct 42 ms 120320 KB Output is correct
6 Correct 42 ms 120268 KB Output is correct
7 Correct 43 ms 120144 KB Output is correct
8 Correct 41 ms 120076 KB Output is correct
9 Correct 42 ms 120704 KB Output is correct
10 Correct 42 ms 120716 KB Output is correct
11 Correct 48 ms 120752 KB Output is correct
12 Correct 43 ms 120652 KB Output is correct
13 Correct 43 ms 120256 KB Output is correct
14 Correct 45 ms 120352 KB Output is correct
15 Correct 43 ms 120136 KB Output is correct
16 Correct 42 ms 120028 KB Output is correct
17 Correct 42 ms 120744 KB Output is correct
18 Correct 43 ms 120684 KB Output is correct
19 Correct 43 ms 120576 KB Output is correct
20 Correct 43 ms 120696 KB Output is correct
21 Correct 43 ms 120272 KB Output is correct
22 Correct 43 ms 120296 KB Output is correct
23 Correct 42 ms 120064 KB Output is correct
24 Correct 43 ms 120088 KB Output is correct
25 Correct 44 ms 122700 KB Output is correct
26 Correct 44 ms 122708 KB Output is correct
27 Correct 47 ms 124128 KB Output is correct
28 Correct 46 ms 124076 KB Output is correct
29 Correct 49 ms 120724 KB Output is correct
30 Correct 44 ms 120744 KB Output is correct
31 Correct 53 ms 121548 KB Output is correct
32 Correct 45 ms 121600 KB Output is correct
33 Correct 44 ms 121632 KB Output is correct
34 Correct 51 ms 121592 KB Output is correct
35 Correct 45 ms 122220 KB Output is correct
36 Correct 45 ms 122292 KB Output is correct
37 Correct 50 ms 124056 KB Output is correct
38 Correct 46 ms 123972 KB Output is correct
39 Correct 44 ms 120716 KB Output is correct
40 Correct 48 ms 120888 KB Output is correct
41 Correct 44 ms 121536 KB Output is correct
42 Correct 45 ms 121560 KB Output is correct
43 Correct 45 ms 122060 KB Output is correct
44 Correct 52 ms 122176 KB Output is correct
45 Correct 46 ms 123620 KB Output is correct
46 Correct 46 ms 123864 KB Output is correct
47 Correct 44 ms 120792 KB Output is correct
48 Correct 46 ms 120768 KB Output is correct
49 Correct 46 ms 121548 KB Output is correct
50 Correct 45 ms 121556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 120920 KB Output is correct
2 Correct 42 ms 120908 KB Output is correct
3 Correct 47 ms 120756 KB Output is correct
4 Correct 42 ms 120780 KB Output is correct
5 Correct 42 ms 120320 KB Output is correct
6 Correct 42 ms 120268 KB Output is correct
7 Correct 43 ms 120144 KB Output is correct
8 Correct 41 ms 120076 KB Output is correct
9 Correct 42 ms 120704 KB Output is correct
10 Correct 42 ms 120716 KB Output is correct
11 Correct 48 ms 120752 KB Output is correct
12 Correct 43 ms 120652 KB Output is correct
13 Correct 43 ms 120256 KB Output is correct
14 Correct 45 ms 120352 KB Output is correct
15 Correct 43 ms 120136 KB Output is correct
16 Correct 42 ms 120028 KB Output is correct
17 Correct 42 ms 120744 KB Output is correct
18 Correct 43 ms 120684 KB Output is correct
19 Correct 43 ms 120576 KB Output is correct
20 Correct 43 ms 120696 KB Output is correct
21 Correct 43 ms 120272 KB Output is correct
22 Correct 43 ms 120296 KB Output is correct
23 Correct 42 ms 120064 KB Output is correct
24 Correct 43 ms 120088 KB Output is correct
25 Correct 108 ms 172932 KB Output is correct
26 Correct 96 ms 173148 KB Output is correct
27 Correct 106 ms 171736 KB Output is correct
28 Correct 105 ms 171412 KB Output is correct
29 Correct 73 ms 133836 KB Output is correct
30 Correct 82 ms 133680 KB Output is correct
31 Correct 47 ms 122232 KB Output is correct
32 Correct 47 ms 122204 KB Output is correct
33 Correct 50 ms 122196 KB Output is correct
34 Correct 48 ms 122284 KB Output is correct
35 Correct 98 ms 163808 KB Output is correct
36 Correct 98 ms 164044 KB Output is correct
37 Correct 107 ms 169828 KB Output is correct
38 Correct 107 ms 169536 KB Output is correct
39 Correct 75 ms 131796 KB Output is correct
40 Correct 84 ms 131724 KB Output is correct
41 Correct 48 ms 122016 KB Output is correct
42 Correct 57 ms 121932 KB Output is correct
43 Correct 107 ms 160660 KB Output is correct
44 Correct 98 ms 160620 KB Output is correct
45 Correct 109 ms 164428 KB Output is correct
46 Correct 108 ms 163460 KB Output is correct
47 Correct 73 ms 131004 KB Output is correct
48 Correct 75 ms 131276 KB Output is correct
49 Correct 44 ms 122320 KB Output is correct
50 Correct 41 ms 121804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 120920 KB Output is correct
2 Correct 42 ms 120908 KB Output is correct
3 Correct 47 ms 120756 KB Output is correct
4 Correct 42 ms 120780 KB Output is correct
5 Correct 42 ms 120320 KB Output is correct
6 Correct 42 ms 120268 KB Output is correct
7 Correct 43 ms 120144 KB Output is correct
8 Correct 41 ms 120076 KB Output is correct
9 Correct 42 ms 120704 KB Output is correct
10 Correct 42 ms 120716 KB Output is correct
11 Correct 48 ms 120752 KB Output is correct
12 Correct 43 ms 120652 KB Output is correct
13 Correct 43 ms 120256 KB Output is correct
14 Correct 45 ms 120352 KB Output is correct
15 Correct 43 ms 120136 KB Output is correct
16 Correct 42 ms 120028 KB Output is correct
17 Correct 42 ms 120744 KB Output is correct
18 Correct 43 ms 120684 KB Output is correct
19 Correct 43 ms 120576 KB Output is correct
20 Correct 43 ms 120696 KB Output is correct
21 Correct 43 ms 120272 KB Output is correct
22 Correct 43 ms 120296 KB Output is correct
23 Correct 42 ms 120064 KB Output is correct
24 Correct 43 ms 120088 KB Output is correct
25 Correct 108 ms 172932 KB Output is correct
26 Correct 96 ms 173148 KB Output is correct
27 Correct 106 ms 171736 KB Output is correct
28 Correct 105 ms 171412 KB Output is correct
29 Correct 73 ms 133836 KB Output is correct
30 Correct 82 ms 133680 KB Output is correct
31 Correct 47 ms 122232 KB Output is correct
32 Correct 47 ms 122204 KB Output is correct
33 Correct 50 ms 122196 KB Output is correct
34 Correct 48 ms 122284 KB Output is correct
35 Correct 98 ms 163808 KB Output is correct
36 Correct 98 ms 164044 KB Output is correct
37 Correct 107 ms 169828 KB Output is correct
38 Correct 107 ms 169536 KB Output is correct
39 Correct 75 ms 131796 KB Output is correct
40 Correct 84 ms 131724 KB Output is correct
41 Correct 48 ms 122016 KB Output is correct
42 Correct 57 ms 121932 KB Output is correct
43 Correct 107 ms 160660 KB Output is correct
44 Correct 98 ms 160620 KB Output is correct
45 Correct 109 ms 164428 KB Output is correct
46 Correct 108 ms 163460 KB Output is correct
47 Correct 73 ms 131004 KB Output is correct
48 Correct 75 ms 131276 KB Output is correct
49 Correct 44 ms 122320 KB Output is correct
50 Correct 41 ms 121804 KB Output is correct
51 Correct 211 ms 263548 KB Output is correct
52 Correct 201 ms 263684 KB Output is correct
53 Correct 216 ms 262472 KB Output is correct
54 Correct 224 ms 262228 KB Output is correct
55 Correct 148 ms 155752 KB Output is correct
56 Correct 136 ms 155980 KB Output is correct
57 Correct 63 ms 128576 KB Output is correct
58 Correct 72 ms 128488 KB Output is correct
59 Correct 60 ms 128740 KB Output is correct
60 Correct 69 ms 128796 KB Output is correct
61 Correct 222 ms 238296 KB Output is correct
62 Correct 199 ms 238360 KB Output is correct
63 Correct 269 ms 257136 KB Output is correct
64 Correct 253 ms 256716 KB Output is correct
65 Correct 159 ms 151572 KB Output is correct
66 Correct 147 ms 151288 KB Output is correct
67 Correct 62 ms 127804 KB Output is correct
68 Correct 63 ms 127552 KB Output is correct
69 Correct 199 ms 229608 KB Output is correct
70 Correct 224 ms 229624 KB Output is correct
71 Correct 246 ms 246148 KB Output is correct
72 Correct 278 ms 245528 KB Output is correct
73 Correct 174 ms 149572 KB Output is correct
74 Correct 158 ms 149328 KB Output is correct
75 Correct 67 ms 127512 KB Output is correct
76 Correct 63 ms 128280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 120920 KB Output is correct
2 Correct 42 ms 120908 KB Output is correct
3 Correct 47 ms 120756 KB Output is correct
4 Correct 42 ms 120780 KB Output is correct
5 Correct 42 ms 120320 KB Output is correct
6 Correct 42 ms 120268 KB Output is correct
7 Correct 43 ms 120144 KB Output is correct
8 Correct 41 ms 120076 KB Output is correct
9 Correct 42 ms 120704 KB Output is correct
10 Correct 42 ms 120716 KB Output is correct
11 Correct 48 ms 120752 KB Output is correct
12 Correct 43 ms 120652 KB Output is correct
13 Correct 43 ms 120256 KB Output is correct
14 Correct 45 ms 120352 KB Output is correct
15 Correct 43 ms 120136 KB Output is correct
16 Correct 42 ms 120028 KB Output is correct
17 Correct 42 ms 120744 KB Output is correct
18 Correct 43 ms 120684 KB Output is correct
19 Correct 43 ms 120576 KB Output is correct
20 Correct 43 ms 120696 KB Output is correct
21 Correct 43 ms 120272 KB Output is correct
22 Correct 43 ms 120296 KB Output is correct
23 Correct 42 ms 120064 KB Output is correct
24 Correct 43 ms 120088 KB Output is correct
25 Correct 44 ms 122700 KB Output is correct
26 Correct 44 ms 122708 KB Output is correct
27 Correct 47 ms 124128 KB Output is correct
28 Correct 46 ms 124076 KB Output is correct
29 Correct 49 ms 120724 KB Output is correct
30 Correct 44 ms 120744 KB Output is correct
31 Correct 53 ms 121548 KB Output is correct
32 Correct 45 ms 121600 KB Output is correct
33 Correct 44 ms 121632 KB Output is correct
34 Correct 51 ms 121592 KB Output is correct
35 Correct 45 ms 122220 KB Output is correct
36 Correct 45 ms 122292 KB Output is correct
37 Correct 50 ms 124056 KB Output is correct
38 Correct 46 ms 123972 KB Output is correct
39 Correct 44 ms 120716 KB Output is correct
40 Correct 48 ms 120888 KB Output is correct
41 Correct 44 ms 121536 KB Output is correct
42 Correct 45 ms 121560 KB Output is correct
43 Correct 45 ms 122060 KB Output is correct
44 Correct 52 ms 122176 KB Output is correct
45 Correct 46 ms 123620 KB Output is correct
46 Correct 46 ms 123864 KB Output is correct
47 Correct 44 ms 120792 KB Output is correct
48 Correct 46 ms 120768 KB Output is correct
49 Correct 46 ms 121548 KB Output is correct
50 Correct 45 ms 121556 KB Output is correct
51 Correct 108 ms 172932 KB Output is correct
52 Correct 96 ms 173148 KB Output is correct
53 Correct 106 ms 171736 KB Output is correct
54 Correct 105 ms 171412 KB Output is correct
55 Correct 73 ms 133836 KB Output is correct
56 Correct 82 ms 133680 KB Output is correct
57 Correct 47 ms 122232 KB Output is correct
58 Correct 47 ms 122204 KB Output is correct
59 Correct 50 ms 122196 KB Output is correct
60 Correct 48 ms 122284 KB Output is correct
61 Correct 98 ms 163808 KB Output is correct
62 Correct 98 ms 164044 KB Output is correct
63 Correct 107 ms 169828 KB Output is correct
64 Correct 107 ms 169536 KB Output is correct
65 Correct 75 ms 131796 KB Output is correct
66 Correct 84 ms 131724 KB Output is correct
67 Correct 48 ms 122016 KB Output is correct
68 Correct 57 ms 121932 KB Output is correct
69 Correct 107 ms 160660 KB Output is correct
70 Correct 98 ms 160620 KB Output is correct
71 Correct 109 ms 164428 KB Output is correct
72 Correct 108 ms 163460 KB Output is correct
73 Correct 73 ms 131004 KB Output is correct
74 Correct 75 ms 131276 KB Output is correct
75 Correct 44 ms 122320 KB Output is correct
76 Correct 41 ms 121804 KB Output is correct
77 Correct 211 ms 263548 KB Output is correct
78 Correct 201 ms 263684 KB Output is correct
79 Correct 216 ms 262472 KB Output is correct
80 Correct 224 ms 262228 KB Output is correct
81 Correct 148 ms 155752 KB Output is correct
82 Correct 136 ms 155980 KB Output is correct
83 Correct 63 ms 128576 KB Output is correct
84 Correct 72 ms 128488 KB Output is correct
85 Correct 60 ms 128740 KB Output is correct
86 Correct 69 ms 128796 KB Output is correct
87 Correct 222 ms 238296 KB Output is correct
88 Correct 199 ms 238360 KB Output is correct
89 Correct 269 ms 257136 KB Output is correct
90 Correct 253 ms 256716 KB Output is correct
91 Correct 159 ms 151572 KB Output is correct
92 Correct 147 ms 151288 KB Output is correct
93 Correct 62 ms 127804 KB Output is correct
94 Correct 63 ms 127552 KB Output is correct
95 Correct 199 ms 229608 KB Output is correct
96 Correct 224 ms 229624 KB Output is correct
97 Correct 246 ms 246148 KB Output is correct
98 Correct 278 ms 245528 KB Output is correct
99 Correct 174 ms 149572 KB Output is correct
100 Correct 158 ms 149328 KB Output is correct
101 Correct 67 ms 127512 KB Output is correct
102 Correct 63 ms 128280 KB Output is correct
103 Correct 352 ms 389436 KB Output is correct
104 Correct 289 ms 389288 KB Output is correct
105 Correct 533 ms 478364 KB Output is correct
106 Correct 520 ms 478548 KB Output is correct
107 Correct 217 ms 186344 KB Output is correct
108 Correct 211 ms 186776 KB Output is correct
109 Correct 86 ms 145784 KB Output is correct
110 Correct 87 ms 145832 KB Output is correct
111 Correct 94 ms 145680 KB Output is correct
112 Correct 92 ms 145700 KB Output is correct
113 Correct 321 ms 342576 KB Output is correct
114 Correct 308 ms 342288 KB Output is correct
115 Runtime error 970 ms 524288 KB Execution killed with signal 11
116 Halted 0 ms 0 KB -