답안 #761370

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
761370 2023-06-19T14:41:25 Z Dan4Life Vinjete (COI22_vinjete) C++17
40 / 100
279 ms 341376 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)1e7/mxN;
int n, mx, IND = 1;
int segTree[mxN*Lg], lazy[mxN*Lg];
vector<pair<int,pair<int,int>>> adj[mxN];
int ans[mxN], root[mxN], L[mxN*Lg], R[mxN*Lg];
 
int newLeaf(int v){ int p = ++IND; segTree[p]=v; return p; }
 
int newParent(int l, int r){
	int p = ++IND; L[p]=l, R[p]=r; lazy[p]=-1;
	segTree[p] = segTree[L[p]]+segTree[R[p]];
	return p;
}
 
int newLazyChild(int p, int v, int l, int r){
	int ind = ++IND;
    L[ind] = L[p];
    R[ind] = R[p];
    lazy[ind] = v;
    segTree[ind] = (r-l+1)*v;
	return ind;
}
 
void prop(int p, int l, int r){
	if(!p or l==r or lazy[p]==-1) return;
	int mid = (l+r)/2;
    if(!L[p]) L[p]=++IND;
    if(!R[p]) R[p]=++IND;
	L[p] = newLazyChild(L[p],lazy[p],l,mid);
	R[p] = newLazyChild(R[p],lazy[p],mid+1,r);
	lazy[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 newLazyChild(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));
}
 
int query(int i, int j, int p, int l=1, int r=mx){
	if(i>r or j<l or i>j or !p) return 0; prop(p,l,r);
	if(i<=l and r<=j) return segTree[p];
	int mid = (l+r)/2;
	return query(i,j,L[p],l,mid)+query(i,j,R[p],mid+1,r);
}
 
void dfs(int s, int p){
    ans[s] = segTree[root[s]];
    for(auto x : adj[s]){
        int u = x.fi; if(u==p) continue;
        root[u] = upd(x.se.fi,x.se.se,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(lazy,-1,sizeof(lazy));
    for(int i = 1; i < n; i++){
        int a, b, l, r; cin >> a >> b >> l >> r;
        adj[a].pb({b,mp(l,r)}); adj[b].pb({a,mp(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);
      |                                        ^~~~
Main.cpp: In function 'int query(int, int, int, int, int)':
Main.cpp:51:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   51 |  if(i>r or j<l or i>j or !p) return 0; prop(p,l,r);
      |  ^~
Main.cpp:51:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   51 |  if(i>r or j<l or i>j or !p) return 0; prop(p,l,r);
      |                                        ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 42196 KB Output is correct
2 Correct 18 ms 42252 KB Output is correct
3 Correct 17 ms 42076 KB Output is correct
4 Correct 17 ms 42168 KB Output is correct
5 Correct 17 ms 41708 KB Output is correct
6 Correct 17 ms 41688 KB Output is correct
7 Correct 17 ms 41428 KB Output is correct
8 Correct 17 ms 41428 KB Output is correct
9 Correct 17 ms 42068 KB Output is correct
10 Correct 18 ms 42152 KB Output is correct
11 Correct 17 ms 42068 KB Output is correct
12 Correct 17 ms 42068 KB Output is correct
13 Correct 17 ms 41572 KB Output is correct
14 Correct 17 ms 41620 KB Output is correct
15 Correct 17 ms 41364 KB Output is correct
16 Correct 17 ms 41424 KB Output is correct
17 Correct 17 ms 42068 KB Output is correct
18 Correct 17 ms 42068 KB Output is correct
19 Correct 17 ms 41940 KB Output is correct
20 Correct 17 ms 41960 KB Output is correct
21 Correct 17 ms 41560 KB Output is correct
22 Correct 17 ms 41592 KB Output is correct
23 Correct 16 ms 41428 KB Output is correct
24 Correct 17 ms 41452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 42196 KB Output is correct
2 Correct 18 ms 42252 KB Output is correct
3 Correct 17 ms 42076 KB Output is correct
4 Correct 17 ms 42168 KB Output is correct
5 Correct 17 ms 41708 KB Output is correct
6 Correct 17 ms 41688 KB Output is correct
7 Correct 17 ms 41428 KB Output is correct
8 Correct 17 ms 41428 KB Output is correct
9 Correct 17 ms 42068 KB Output is correct
10 Correct 18 ms 42152 KB Output is correct
11 Correct 17 ms 42068 KB Output is correct
12 Correct 17 ms 42068 KB Output is correct
13 Correct 17 ms 41572 KB Output is correct
14 Correct 17 ms 41620 KB Output is correct
15 Correct 17 ms 41364 KB Output is correct
16 Correct 17 ms 41424 KB Output is correct
17 Correct 17 ms 42068 KB Output is correct
18 Correct 17 ms 42068 KB Output is correct
19 Correct 17 ms 41940 KB Output is correct
20 Correct 17 ms 41960 KB Output is correct
21 Correct 17 ms 41560 KB Output is correct
22 Correct 17 ms 41592 KB Output is correct
23 Correct 16 ms 41428 KB Output is correct
24 Correct 17 ms 41452 KB Output is correct
25 Correct 18 ms 44132 KB Output is correct
26 Correct 19 ms 44104 KB Output is correct
27 Correct 20 ms 45360 KB Output is correct
28 Correct 24 ms 45388 KB Output is correct
29 Correct 18 ms 42148 KB Output is correct
30 Correct 18 ms 42192 KB Output is correct
31 Correct 23 ms 42944 KB Output is correct
32 Correct 22 ms 42900 KB Output is correct
33 Correct 18 ms 42964 KB Output is correct
34 Correct 18 ms 42964 KB Output is correct
35 Correct 18 ms 43564 KB Output is correct
36 Correct 19 ms 43604 KB Output is correct
37 Correct 20 ms 45396 KB Output is correct
38 Correct 20 ms 45400 KB Output is correct
39 Correct 18 ms 42068 KB Output is correct
40 Correct 18 ms 42092 KB Output is correct
41 Correct 20 ms 42924 KB Output is correct
42 Correct 18 ms 42836 KB Output is correct
43 Correct 18 ms 43476 KB Output is correct
44 Correct 19 ms 43488 KB Output is correct
45 Correct 19 ms 44884 KB Output is correct
46 Correct 20 ms 45128 KB Output is correct
47 Correct 18 ms 42032 KB Output is correct
48 Correct 18 ms 42064 KB Output is correct
49 Correct 18 ms 42952 KB Output is correct
50 Correct 18 ms 42896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 42196 KB Output is correct
2 Correct 18 ms 42252 KB Output is correct
3 Correct 17 ms 42076 KB Output is correct
4 Correct 17 ms 42168 KB Output is correct
5 Correct 17 ms 41708 KB Output is correct
6 Correct 17 ms 41688 KB Output is correct
7 Correct 17 ms 41428 KB Output is correct
8 Correct 17 ms 41428 KB Output is correct
9 Correct 17 ms 42068 KB Output is correct
10 Correct 18 ms 42152 KB Output is correct
11 Correct 17 ms 42068 KB Output is correct
12 Correct 17 ms 42068 KB Output is correct
13 Correct 17 ms 41572 KB Output is correct
14 Correct 17 ms 41620 KB Output is correct
15 Correct 17 ms 41364 KB Output is correct
16 Correct 17 ms 41424 KB Output is correct
17 Correct 17 ms 42068 KB Output is correct
18 Correct 17 ms 42068 KB Output is correct
19 Correct 17 ms 41940 KB Output is correct
20 Correct 17 ms 41960 KB Output is correct
21 Correct 17 ms 41560 KB Output is correct
22 Correct 17 ms 41592 KB Output is correct
23 Correct 16 ms 41428 KB Output is correct
24 Correct 17 ms 41452 KB Output is correct
25 Correct 69 ms 94056 KB Output is correct
26 Correct 70 ms 94228 KB Output is correct
27 Correct 78 ms 92520 KB Output is correct
28 Correct 77 ms 92392 KB Output is correct
29 Correct 51 ms 54688 KB Output is correct
30 Correct 46 ms 54740 KB Output is correct
31 Correct 20 ms 43476 KB Output is correct
32 Correct 20 ms 43476 KB Output is correct
33 Correct 20 ms 43516 KB Output is correct
34 Correct 21 ms 43476 KB Output is correct
35 Correct 71 ms 84804 KB Output is correct
36 Correct 72 ms 85004 KB Output is correct
37 Correct 80 ms 90840 KB Output is correct
38 Correct 81 ms 90512 KB Output is correct
39 Correct 47 ms 52720 KB Output is correct
40 Correct 48 ms 52808 KB Output is correct
41 Correct 20 ms 43348 KB Output is correct
42 Correct 20 ms 43208 KB Output is correct
43 Correct 69 ms 81512 KB Output is correct
44 Correct 70 ms 81632 KB Output is correct
45 Correct 80 ms 85304 KB Output is correct
46 Correct 82 ms 84472 KB Output is correct
47 Correct 48 ms 52008 KB Output is correct
48 Correct 49 ms 52084 KB Output is correct
49 Correct 20 ms 43616 KB Output is correct
50 Correct 21 ms 43232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 42196 KB Output is correct
2 Correct 18 ms 42252 KB Output is correct
3 Correct 17 ms 42076 KB Output is correct
4 Correct 17 ms 42168 KB Output is correct
5 Correct 17 ms 41708 KB Output is correct
6 Correct 17 ms 41688 KB Output is correct
7 Correct 17 ms 41428 KB Output is correct
8 Correct 17 ms 41428 KB Output is correct
9 Correct 17 ms 42068 KB Output is correct
10 Correct 18 ms 42152 KB Output is correct
11 Correct 17 ms 42068 KB Output is correct
12 Correct 17 ms 42068 KB Output is correct
13 Correct 17 ms 41572 KB Output is correct
14 Correct 17 ms 41620 KB Output is correct
15 Correct 17 ms 41364 KB Output is correct
16 Correct 17 ms 41424 KB Output is correct
17 Correct 17 ms 42068 KB Output is correct
18 Correct 17 ms 42068 KB Output is correct
19 Correct 17 ms 41940 KB Output is correct
20 Correct 17 ms 41960 KB Output is correct
21 Correct 17 ms 41560 KB Output is correct
22 Correct 17 ms 41592 KB Output is correct
23 Correct 16 ms 41428 KB Output is correct
24 Correct 17 ms 41452 KB Output is correct
25 Correct 69 ms 94056 KB Output is correct
26 Correct 70 ms 94228 KB Output is correct
27 Correct 78 ms 92520 KB Output is correct
28 Correct 77 ms 92392 KB Output is correct
29 Correct 51 ms 54688 KB Output is correct
30 Correct 46 ms 54740 KB Output is correct
31 Correct 20 ms 43476 KB Output is correct
32 Correct 20 ms 43476 KB Output is correct
33 Correct 20 ms 43516 KB Output is correct
34 Correct 21 ms 43476 KB Output is correct
35 Correct 71 ms 84804 KB Output is correct
36 Correct 72 ms 85004 KB Output is correct
37 Correct 80 ms 90840 KB Output is correct
38 Correct 81 ms 90512 KB Output is correct
39 Correct 47 ms 52720 KB Output is correct
40 Correct 48 ms 52808 KB Output is correct
41 Correct 20 ms 43348 KB Output is correct
42 Correct 20 ms 43208 KB Output is correct
43 Correct 69 ms 81512 KB Output is correct
44 Correct 70 ms 81632 KB Output is correct
45 Correct 80 ms 85304 KB Output is correct
46 Correct 82 ms 84472 KB Output is correct
47 Correct 48 ms 52008 KB Output is correct
48 Correct 49 ms 52084 KB Output is correct
49 Correct 20 ms 43616 KB Output is correct
50 Correct 21 ms 43232 KB Output is correct
51 Runtime error 279 ms 341376 KB Execution killed with signal 11
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 42196 KB Output is correct
2 Correct 18 ms 42252 KB Output is correct
3 Correct 17 ms 42076 KB Output is correct
4 Correct 17 ms 42168 KB Output is correct
5 Correct 17 ms 41708 KB Output is correct
6 Correct 17 ms 41688 KB Output is correct
7 Correct 17 ms 41428 KB Output is correct
8 Correct 17 ms 41428 KB Output is correct
9 Correct 17 ms 42068 KB Output is correct
10 Correct 18 ms 42152 KB Output is correct
11 Correct 17 ms 42068 KB Output is correct
12 Correct 17 ms 42068 KB Output is correct
13 Correct 17 ms 41572 KB Output is correct
14 Correct 17 ms 41620 KB Output is correct
15 Correct 17 ms 41364 KB Output is correct
16 Correct 17 ms 41424 KB Output is correct
17 Correct 17 ms 42068 KB Output is correct
18 Correct 17 ms 42068 KB Output is correct
19 Correct 17 ms 41940 KB Output is correct
20 Correct 17 ms 41960 KB Output is correct
21 Correct 17 ms 41560 KB Output is correct
22 Correct 17 ms 41592 KB Output is correct
23 Correct 16 ms 41428 KB Output is correct
24 Correct 17 ms 41452 KB Output is correct
25 Correct 18 ms 44132 KB Output is correct
26 Correct 19 ms 44104 KB Output is correct
27 Correct 20 ms 45360 KB Output is correct
28 Correct 24 ms 45388 KB Output is correct
29 Correct 18 ms 42148 KB Output is correct
30 Correct 18 ms 42192 KB Output is correct
31 Correct 23 ms 42944 KB Output is correct
32 Correct 22 ms 42900 KB Output is correct
33 Correct 18 ms 42964 KB Output is correct
34 Correct 18 ms 42964 KB Output is correct
35 Correct 18 ms 43564 KB Output is correct
36 Correct 19 ms 43604 KB Output is correct
37 Correct 20 ms 45396 KB Output is correct
38 Correct 20 ms 45400 KB Output is correct
39 Correct 18 ms 42068 KB Output is correct
40 Correct 18 ms 42092 KB Output is correct
41 Correct 20 ms 42924 KB Output is correct
42 Correct 18 ms 42836 KB Output is correct
43 Correct 18 ms 43476 KB Output is correct
44 Correct 19 ms 43488 KB Output is correct
45 Correct 19 ms 44884 KB Output is correct
46 Correct 20 ms 45128 KB Output is correct
47 Correct 18 ms 42032 KB Output is correct
48 Correct 18 ms 42064 KB Output is correct
49 Correct 18 ms 42952 KB Output is correct
50 Correct 18 ms 42896 KB Output is correct
51 Correct 69 ms 94056 KB Output is correct
52 Correct 70 ms 94228 KB Output is correct
53 Correct 78 ms 92520 KB Output is correct
54 Correct 77 ms 92392 KB Output is correct
55 Correct 51 ms 54688 KB Output is correct
56 Correct 46 ms 54740 KB Output is correct
57 Correct 20 ms 43476 KB Output is correct
58 Correct 20 ms 43476 KB Output is correct
59 Correct 20 ms 43516 KB Output is correct
60 Correct 21 ms 43476 KB Output is correct
61 Correct 71 ms 84804 KB Output is correct
62 Correct 72 ms 85004 KB Output is correct
63 Correct 80 ms 90840 KB Output is correct
64 Correct 81 ms 90512 KB Output is correct
65 Correct 47 ms 52720 KB Output is correct
66 Correct 48 ms 52808 KB Output is correct
67 Correct 20 ms 43348 KB Output is correct
68 Correct 20 ms 43208 KB Output is correct
69 Correct 69 ms 81512 KB Output is correct
70 Correct 70 ms 81632 KB Output is correct
71 Correct 80 ms 85304 KB Output is correct
72 Correct 82 ms 84472 KB Output is correct
73 Correct 48 ms 52008 KB Output is correct
74 Correct 49 ms 52084 KB Output is correct
75 Correct 20 ms 43616 KB Output is correct
76 Correct 21 ms 43232 KB Output is correct
77 Runtime error 279 ms 341376 KB Execution killed with signal 11
78 Halted 0 ms 0 KB -