답안 #767224

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767224 2023-06-26T14:19:05 Z Dan4Life Vinjete (COI22_vinjete) C++17
100 / 100
492 ms 522108 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
const int mxN = (int)1e5+10;
const int Lg = (int)4e2;
int n, mx, IND = 1;
int seg[mxN*Lg], lzy[mxN*Lg];
vector<array<int,3>> adj[mxN];
int ans[mxN], root[mxN], L[mxN*Lg], R[mxN*Lg];

int newLeaf(int v){ int p = ++IND; seg[p]=v; return p; }

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[root[s]];
	for(auto [u,v,w] : adj[s])
		if(u!=p) root[u] = upd(v,w,1,root[s]), dfs(u,s);
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> mx; root[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].pb({b,l,r}), adj[b].pb({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:42:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   42 |  if(i>r or j<l or i>j or !p) return p; prop(p,l,r);
      |  ^~
Main.cpp:42:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   42 |  if(i>r or j<l or i>j or !p) return p; prop(p,l,r);
      |                                        ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 160044 KB Output is correct
2 Correct 52 ms 160076 KB Output is correct
3 Correct 64 ms 159868 KB Output is correct
4 Correct 56 ms 159964 KB Output is correct
5 Correct 56 ms 159428 KB Output is correct
6 Correct 56 ms 159412 KB Output is correct
7 Correct 59 ms 159272 KB Output is correct
8 Correct 53 ms 159312 KB Output is correct
9 Correct 56 ms 159976 KB Output is correct
10 Correct 53 ms 159948 KB Output is correct
11 Correct 52 ms 159884 KB Output is correct
12 Correct 54 ms 159812 KB Output is correct
13 Correct 53 ms 159368 KB Output is correct
14 Correct 52 ms 159440 KB Output is correct
15 Correct 51 ms 159268 KB Output is correct
16 Correct 59 ms 159412 KB Output is correct
17 Correct 59 ms 159908 KB Output is correct
18 Correct 65 ms 159888 KB Output is correct
19 Correct 55 ms 159768 KB Output is correct
20 Correct 53 ms 159712 KB Output is correct
21 Correct 54 ms 159340 KB Output is correct
22 Correct 54 ms 159464 KB Output is correct
23 Correct 61 ms 159184 KB Output is correct
24 Correct 61 ms 159180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 160044 KB Output is correct
2 Correct 52 ms 160076 KB Output is correct
3 Correct 64 ms 159868 KB Output is correct
4 Correct 56 ms 159964 KB Output is correct
5 Correct 56 ms 159428 KB Output is correct
6 Correct 56 ms 159412 KB Output is correct
7 Correct 59 ms 159272 KB Output is correct
8 Correct 53 ms 159312 KB Output is correct
9 Correct 56 ms 159976 KB Output is correct
10 Correct 53 ms 159948 KB Output is correct
11 Correct 52 ms 159884 KB Output is correct
12 Correct 54 ms 159812 KB Output is correct
13 Correct 53 ms 159368 KB Output is correct
14 Correct 52 ms 159440 KB Output is correct
15 Correct 51 ms 159268 KB Output is correct
16 Correct 59 ms 159412 KB Output is correct
17 Correct 59 ms 159908 KB Output is correct
18 Correct 65 ms 159888 KB Output is correct
19 Correct 55 ms 159768 KB Output is correct
20 Correct 53 ms 159712 KB Output is correct
21 Correct 54 ms 159340 KB Output is correct
22 Correct 54 ms 159464 KB Output is correct
23 Correct 61 ms 159184 KB Output is correct
24 Correct 61 ms 159180 KB Output is correct
25 Correct 54 ms 161948 KB Output is correct
26 Correct 57 ms 161864 KB Output is correct
27 Correct 56 ms 163208 KB Output is correct
28 Correct 56 ms 163276 KB Output is correct
29 Correct 55 ms 159940 KB Output is correct
30 Correct 54 ms 159960 KB Output is correct
31 Correct 61 ms 160772 KB Output is correct
32 Correct 55 ms 160716 KB Output is correct
33 Correct 56 ms 160792 KB Output is correct
34 Correct 62 ms 160716 KB Output is correct
35 Correct 55 ms 161460 KB Output is correct
36 Correct 55 ms 161476 KB Output is correct
37 Correct 69 ms 163192 KB Output is correct
38 Correct 62 ms 163120 KB Output is correct
39 Correct 70 ms 159868 KB Output is correct
40 Correct 56 ms 159880 KB Output is correct
41 Correct 55 ms 160752 KB Output is correct
42 Correct 56 ms 160736 KB Output is correct
43 Correct 57 ms 161188 KB Output is correct
44 Correct 59 ms 161272 KB Output is correct
45 Correct 56 ms 162740 KB Output is correct
46 Correct 56 ms 162976 KB Output is correct
47 Correct 55 ms 159896 KB Output is correct
48 Correct 60 ms 159884 KB Output is correct
49 Correct 57 ms 160688 KB Output is correct
50 Correct 56 ms 160776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 160044 KB Output is correct
2 Correct 52 ms 160076 KB Output is correct
3 Correct 64 ms 159868 KB Output is correct
4 Correct 56 ms 159964 KB Output is correct
5 Correct 56 ms 159428 KB Output is correct
6 Correct 56 ms 159412 KB Output is correct
7 Correct 59 ms 159272 KB Output is correct
8 Correct 53 ms 159312 KB Output is correct
9 Correct 56 ms 159976 KB Output is correct
10 Correct 53 ms 159948 KB Output is correct
11 Correct 52 ms 159884 KB Output is correct
12 Correct 54 ms 159812 KB Output is correct
13 Correct 53 ms 159368 KB Output is correct
14 Correct 52 ms 159440 KB Output is correct
15 Correct 51 ms 159268 KB Output is correct
16 Correct 59 ms 159412 KB Output is correct
17 Correct 59 ms 159908 KB Output is correct
18 Correct 65 ms 159888 KB Output is correct
19 Correct 55 ms 159768 KB Output is correct
20 Correct 53 ms 159712 KB Output is correct
21 Correct 54 ms 159340 KB Output is correct
22 Correct 54 ms 159464 KB Output is correct
23 Correct 61 ms 159184 KB Output is correct
24 Correct 61 ms 159180 KB Output is correct
25 Correct 119 ms 212068 KB Output is correct
26 Correct 109 ms 212276 KB Output is correct
27 Correct 126 ms 210764 KB Output is correct
28 Correct 112 ms 210564 KB Output is correct
29 Correct 86 ms 172932 KB Output is correct
30 Correct 87 ms 172824 KB Output is correct
31 Correct 59 ms 161376 KB Output is correct
32 Correct 57 ms 161380 KB Output is correct
33 Correct 58 ms 161356 KB Output is correct
34 Correct 63 ms 161368 KB Output is correct
35 Correct 108 ms 202984 KB Output is correct
36 Correct 107 ms 203180 KB Output is correct
37 Correct 122 ms 209020 KB Output is correct
38 Correct 116 ms 208644 KB Output is correct
39 Correct 98 ms 171108 KB Output is correct
40 Correct 88 ms 170928 KB Output is correct
41 Correct 59 ms 161136 KB Output is correct
42 Correct 57 ms 161104 KB Output is correct
43 Correct 113 ms 199672 KB Output is correct
44 Correct 122 ms 199856 KB Output is correct
45 Correct 122 ms 203596 KB Output is correct
46 Correct 137 ms 202600 KB Output is correct
47 Correct 90 ms 170116 KB Output is correct
48 Correct 94 ms 170432 KB Output is correct
49 Correct 58 ms 161412 KB Output is correct
50 Correct 60 ms 160948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 160044 KB Output is correct
2 Correct 52 ms 160076 KB Output is correct
3 Correct 64 ms 159868 KB Output is correct
4 Correct 56 ms 159964 KB Output is correct
5 Correct 56 ms 159428 KB Output is correct
6 Correct 56 ms 159412 KB Output is correct
7 Correct 59 ms 159272 KB Output is correct
8 Correct 53 ms 159312 KB Output is correct
9 Correct 56 ms 159976 KB Output is correct
10 Correct 53 ms 159948 KB Output is correct
11 Correct 52 ms 159884 KB Output is correct
12 Correct 54 ms 159812 KB Output is correct
13 Correct 53 ms 159368 KB Output is correct
14 Correct 52 ms 159440 KB Output is correct
15 Correct 51 ms 159268 KB Output is correct
16 Correct 59 ms 159412 KB Output is correct
17 Correct 59 ms 159908 KB Output is correct
18 Correct 65 ms 159888 KB Output is correct
19 Correct 55 ms 159768 KB Output is correct
20 Correct 53 ms 159712 KB Output is correct
21 Correct 54 ms 159340 KB Output is correct
22 Correct 54 ms 159464 KB Output is correct
23 Correct 61 ms 159184 KB Output is correct
24 Correct 61 ms 159180 KB Output is correct
25 Correct 119 ms 212068 KB Output is correct
26 Correct 109 ms 212276 KB Output is correct
27 Correct 126 ms 210764 KB Output is correct
28 Correct 112 ms 210564 KB Output is correct
29 Correct 86 ms 172932 KB Output is correct
30 Correct 87 ms 172824 KB Output is correct
31 Correct 59 ms 161376 KB Output is correct
32 Correct 57 ms 161380 KB Output is correct
33 Correct 58 ms 161356 KB Output is correct
34 Correct 63 ms 161368 KB Output is correct
35 Correct 108 ms 202984 KB Output is correct
36 Correct 107 ms 203180 KB Output is correct
37 Correct 122 ms 209020 KB Output is correct
38 Correct 116 ms 208644 KB Output is correct
39 Correct 98 ms 171108 KB Output is correct
40 Correct 88 ms 170928 KB Output is correct
41 Correct 59 ms 161136 KB Output is correct
42 Correct 57 ms 161104 KB Output is correct
43 Correct 113 ms 199672 KB Output is correct
44 Correct 122 ms 199856 KB Output is correct
45 Correct 122 ms 203596 KB Output is correct
46 Correct 137 ms 202600 KB Output is correct
47 Correct 90 ms 170116 KB Output is correct
48 Correct 94 ms 170432 KB Output is correct
49 Correct 58 ms 161412 KB Output is correct
50 Correct 60 ms 160948 KB Output is correct
51 Correct 202 ms 302624 KB Output is correct
52 Correct 203 ms 302796 KB Output is correct
53 Correct 269 ms 301676 KB Output is correct
54 Correct 261 ms 301388 KB Output is correct
55 Correct 138 ms 195084 KB Output is correct
56 Correct 154 ms 195144 KB Output is correct
57 Correct 69 ms 167740 KB Output is correct
58 Correct 69 ms 167668 KB Output is correct
59 Correct 76 ms 167888 KB Output is correct
60 Correct 78 ms 167888 KB Output is correct
61 Correct 206 ms 277388 KB Output is correct
62 Correct 204 ms 277560 KB Output is correct
63 Correct 239 ms 296192 KB Output is correct
64 Correct 261 ms 295856 KB Output is correct
65 Correct 154 ms 190748 KB Output is correct
66 Correct 163 ms 190440 KB Output is correct
67 Correct 70 ms 166856 KB Output is correct
68 Correct 75 ms 166764 KB Output is correct
69 Correct 227 ms 268732 KB Output is correct
70 Correct 205 ms 268740 KB Output is correct
71 Correct 269 ms 285324 KB Output is correct
72 Correct 242 ms 284604 KB Output is correct
73 Correct 159 ms 188724 KB Output is correct
74 Correct 183 ms 188496 KB Output is correct
75 Correct 73 ms 166648 KB Output is correct
76 Correct 74 ms 167384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 160044 KB Output is correct
2 Correct 52 ms 160076 KB Output is correct
3 Correct 64 ms 159868 KB Output is correct
4 Correct 56 ms 159964 KB Output is correct
5 Correct 56 ms 159428 KB Output is correct
6 Correct 56 ms 159412 KB Output is correct
7 Correct 59 ms 159272 KB Output is correct
8 Correct 53 ms 159312 KB Output is correct
9 Correct 56 ms 159976 KB Output is correct
10 Correct 53 ms 159948 KB Output is correct
11 Correct 52 ms 159884 KB Output is correct
12 Correct 54 ms 159812 KB Output is correct
13 Correct 53 ms 159368 KB Output is correct
14 Correct 52 ms 159440 KB Output is correct
15 Correct 51 ms 159268 KB Output is correct
16 Correct 59 ms 159412 KB Output is correct
17 Correct 59 ms 159908 KB Output is correct
18 Correct 65 ms 159888 KB Output is correct
19 Correct 55 ms 159768 KB Output is correct
20 Correct 53 ms 159712 KB Output is correct
21 Correct 54 ms 159340 KB Output is correct
22 Correct 54 ms 159464 KB Output is correct
23 Correct 61 ms 159184 KB Output is correct
24 Correct 61 ms 159180 KB Output is correct
25 Correct 54 ms 161948 KB Output is correct
26 Correct 57 ms 161864 KB Output is correct
27 Correct 56 ms 163208 KB Output is correct
28 Correct 56 ms 163276 KB Output is correct
29 Correct 55 ms 159940 KB Output is correct
30 Correct 54 ms 159960 KB Output is correct
31 Correct 61 ms 160772 KB Output is correct
32 Correct 55 ms 160716 KB Output is correct
33 Correct 56 ms 160792 KB Output is correct
34 Correct 62 ms 160716 KB Output is correct
35 Correct 55 ms 161460 KB Output is correct
36 Correct 55 ms 161476 KB Output is correct
37 Correct 69 ms 163192 KB Output is correct
38 Correct 62 ms 163120 KB Output is correct
39 Correct 70 ms 159868 KB Output is correct
40 Correct 56 ms 159880 KB Output is correct
41 Correct 55 ms 160752 KB Output is correct
42 Correct 56 ms 160736 KB Output is correct
43 Correct 57 ms 161188 KB Output is correct
44 Correct 59 ms 161272 KB Output is correct
45 Correct 56 ms 162740 KB Output is correct
46 Correct 56 ms 162976 KB Output is correct
47 Correct 55 ms 159896 KB Output is correct
48 Correct 60 ms 159884 KB Output is correct
49 Correct 57 ms 160688 KB Output is correct
50 Correct 56 ms 160776 KB Output is correct
51 Correct 119 ms 212068 KB Output is correct
52 Correct 109 ms 212276 KB Output is correct
53 Correct 126 ms 210764 KB Output is correct
54 Correct 112 ms 210564 KB Output is correct
55 Correct 86 ms 172932 KB Output is correct
56 Correct 87 ms 172824 KB Output is correct
57 Correct 59 ms 161376 KB Output is correct
58 Correct 57 ms 161380 KB Output is correct
59 Correct 58 ms 161356 KB Output is correct
60 Correct 63 ms 161368 KB Output is correct
61 Correct 108 ms 202984 KB Output is correct
62 Correct 107 ms 203180 KB Output is correct
63 Correct 122 ms 209020 KB Output is correct
64 Correct 116 ms 208644 KB Output is correct
65 Correct 98 ms 171108 KB Output is correct
66 Correct 88 ms 170928 KB Output is correct
67 Correct 59 ms 161136 KB Output is correct
68 Correct 57 ms 161104 KB Output is correct
69 Correct 113 ms 199672 KB Output is correct
70 Correct 122 ms 199856 KB Output is correct
71 Correct 122 ms 203596 KB Output is correct
72 Correct 137 ms 202600 KB Output is correct
73 Correct 90 ms 170116 KB Output is correct
74 Correct 94 ms 170432 KB Output is correct
75 Correct 58 ms 161412 KB Output is correct
76 Correct 60 ms 160948 KB Output is correct
77 Correct 202 ms 302624 KB Output is correct
78 Correct 203 ms 302796 KB Output is correct
79 Correct 269 ms 301676 KB Output is correct
80 Correct 261 ms 301388 KB Output is correct
81 Correct 138 ms 195084 KB Output is correct
82 Correct 154 ms 195144 KB Output is correct
83 Correct 69 ms 167740 KB Output is correct
84 Correct 69 ms 167668 KB Output is correct
85 Correct 76 ms 167888 KB Output is correct
86 Correct 78 ms 167888 KB Output is correct
87 Correct 206 ms 277388 KB Output is correct
88 Correct 204 ms 277560 KB Output is correct
89 Correct 239 ms 296192 KB Output is correct
90 Correct 261 ms 295856 KB Output is correct
91 Correct 154 ms 190748 KB Output is correct
92 Correct 163 ms 190440 KB Output is correct
93 Correct 70 ms 166856 KB Output is correct
94 Correct 75 ms 166764 KB Output is correct
95 Correct 227 ms 268732 KB Output is correct
96 Correct 205 ms 268740 KB Output is correct
97 Correct 269 ms 285324 KB Output is correct
98 Correct 242 ms 284604 KB Output is correct
99 Correct 159 ms 188724 KB Output is correct
100 Correct 183 ms 188496 KB Output is correct
101 Correct 73 ms 166648 KB Output is correct
102 Correct 74 ms 167384 KB Output is correct
103 Correct 309 ms 428616 KB Output is correct
104 Correct 285 ms 428436 KB Output is correct
105 Correct 489 ms 517712 KB Output is correct
106 Correct 492 ms 517616 KB Output is correct
107 Correct 233 ms 225480 KB Output is correct
108 Correct 197 ms 225944 KB Output is correct
109 Correct 90 ms 184908 KB Output is correct
110 Correct 100 ms 185000 KB Output is correct
111 Correct 89 ms 184728 KB Output is correct
112 Correct 90 ms 184896 KB Output is correct
113 Correct 291 ms 381700 KB Output is correct
114 Correct 328 ms 381372 KB Output is correct
115 Correct 452 ms 522108 KB Output is correct
116 Correct 435 ms 520524 KB Output is correct
117 Correct 253 ms 221416 KB Output is correct
118 Correct 194 ms 221508 KB Output is correct
119 Correct 89 ms 184396 KB Output is correct
120 Correct 93 ms 184140 KB Output is correct
121 Correct 289 ms 362848 KB Output is correct
122 Correct 285 ms 362736 KB Output is correct
123 Correct 427 ms 502788 KB Output is correct
124 Correct 419 ms 509760 KB Output is correct
125 Correct 247 ms 219204 KB Output is correct
126 Correct 219 ms 219596 KB Output is correct
127 Correct 105 ms 186036 KB Output is correct
128 Correct 93 ms 185000 KB Output is correct