답안 #959908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
959908 2024-04-09T10:03:11 Z pcc Vinjete (COI22_vinjete) C++17
100 / 100
346 ms 189636 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,sse4")

#define pii pair<int,int>
#define fs first
#define sc second
#define ll long long

const int mxn = 1e5+10;
const int inf = 1e9+10;

struct SEG{
#define ls seg[now].pl
#define rs seg[now].pr
#define mid ((l+r)>>1)
	struct node{
		int pl,pr,tag,cnt;
		node(){
			pl = pr = tag = cnt = 0;
		}
	};
	node seg[mxn*100];
	int ppp = 0;
	int newnode(){
		return ++ppp;
	}
	int modify(int now,int l,int r,int s,int e,int v){
		if(!now)now = newnode();
		if(l>=s&&e>=r){
			seg[now].tag += v;
			return now;
		}
		if(mid>=s)ls = modify(ls,l,mid,s,e,v);
		if(mid<e)rs = modify(rs,mid+1,r,s,e,v);
		seg[now].cnt = (seg[ls].tag?mid-l+1:seg[ls].cnt)+(seg[rs].tag?r-mid:seg[rs].cnt);
		return now;
	}
#undef ls
#undef rs
#undef mid
};

SEG seg;
int N,M;
vector<pii> tree[mxn];
pii edges[mxn];
int ans[mxn];
int rt;

void dfs(int now,int par){
	ans[now] = seg.seg[rt].cnt;
	for(auto [nxt,eid]:tree[now]){
		if(nxt == par)continue;
		auto [l,r] = edges[eid];
		rt = seg.modify(rt,0,M,l,r,1);
		dfs(nxt,now);
		rt = seg.modify(rt,0,M,l,r,-1);
	}
	return;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N>>M;
	for(int i = 1;i<N;i++){
		int a,b,s,e;
		cin>>a>>b>>s>>e;
		edges[i] = pii(s,e);
		tree[a].push_back(pii(b,i));
		tree[b].push_back(pii(a,i));
	}
	dfs(1,1);
	rt = seg.newnode();
	for(int i = 2;i<=N;i++)cout<<ans[i]<<'\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 160596 KB Output is correct
2 Correct 34 ms 160604 KB Output is correct
3 Correct 35 ms 160480 KB Output is correct
4 Correct 34 ms 160592 KB Output is correct
5 Correct 35 ms 160604 KB Output is correct
6 Correct 35 ms 160596 KB Output is correct
7 Correct 34 ms 160180 KB Output is correct
8 Correct 34 ms 160340 KB Output is correct
9 Correct 35 ms 160340 KB Output is correct
10 Correct 35 ms 160336 KB Output is correct
11 Correct 34 ms 160344 KB Output is correct
12 Correct 35 ms 160552 KB Output is correct
13 Correct 35 ms 160444 KB Output is correct
14 Correct 35 ms 160340 KB Output is correct
15 Correct 34 ms 160340 KB Output is correct
16 Correct 34 ms 160348 KB Output is correct
17 Correct 34 ms 160340 KB Output is correct
18 Correct 34 ms 160340 KB Output is correct
19 Correct 34 ms 160340 KB Output is correct
20 Correct 38 ms 160336 KB Output is correct
21 Correct 33 ms 160340 KB Output is correct
22 Correct 35 ms 160336 KB Output is correct
23 Correct 34 ms 160340 KB Output is correct
24 Correct 33 ms 160604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 160596 KB Output is correct
2 Correct 34 ms 160604 KB Output is correct
3 Correct 35 ms 160480 KB Output is correct
4 Correct 34 ms 160592 KB Output is correct
5 Correct 35 ms 160604 KB Output is correct
6 Correct 35 ms 160596 KB Output is correct
7 Correct 34 ms 160180 KB Output is correct
8 Correct 34 ms 160340 KB Output is correct
9 Correct 35 ms 160340 KB Output is correct
10 Correct 35 ms 160336 KB Output is correct
11 Correct 34 ms 160344 KB Output is correct
12 Correct 35 ms 160552 KB Output is correct
13 Correct 35 ms 160444 KB Output is correct
14 Correct 35 ms 160340 KB Output is correct
15 Correct 34 ms 160340 KB Output is correct
16 Correct 34 ms 160348 KB Output is correct
17 Correct 34 ms 160340 KB Output is correct
18 Correct 34 ms 160340 KB Output is correct
19 Correct 34 ms 160340 KB Output is correct
20 Correct 38 ms 160336 KB Output is correct
21 Correct 33 ms 160340 KB Output is correct
22 Correct 35 ms 160336 KB Output is correct
23 Correct 34 ms 160340 KB Output is correct
24 Correct 33 ms 160604 KB Output is correct
25 Correct 36 ms 160448 KB Output is correct
26 Correct 34 ms 160608 KB Output is correct
27 Correct 36 ms 160576 KB Output is correct
28 Correct 35 ms 160592 KB Output is correct
29 Correct 34 ms 160520 KB Output is correct
30 Correct 35 ms 160596 KB Output is correct
31 Correct 35 ms 160596 KB Output is correct
32 Correct 35 ms 160592 KB Output is correct
33 Correct 35 ms 160596 KB Output is correct
34 Correct 37 ms 160636 KB Output is correct
35 Correct 36 ms 160340 KB Output is correct
36 Correct 36 ms 160340 KB Output is correct
37 Correct 35 ms 160348 KB Output is correct
38 Correct 35 ms 160340 KB Output is correct
39 Correct 37 ms 160448 KB Output is correct
40 Correct 34 ms 160348 KB Output is correct
41 Correct 36 ms 160348 KB Output is correct
42 Correct 35 ms 160480 KB Output is correct
43 Correct 35 ms 160352 KB Output is correct
44 Correct 35 ms 160336 KB Output is correct
45 Correct 35 ms 160340 KB Output is correct
46 Correct 35 ms 160340 KB Output is correct
47 Correct 35 ms 160336 KB Output is correct
48 Correct 34 ms 160336 KB Output is correct
49 Correct 36 ms 160336 KB Output is correct
50 Correct 35 ms 160340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 160596 KB Output is correct
2 Correct 34 ms 160604 KB Output is correct
3 Correct 35 ms 160480 KB Output is correct
4 Correct 34 ms 160592 KB Output is correct
5 Correct 35 ms 160604 KB Output is correct
6 Correct 35 ms 160596 KB Output is correct
7 Correct 34 ms 160180 KB Output is correct
8 Correct 34 ms 160340 KB Output is correct
9 Correct 35 ms 160340 KB Output is correct
10 Correct 35 ms 160336 KB Output is correct
11 Correct 34 ms 160344 KB Output is correct
12 Correct 35 ms 160552 KB Output is correct
13 Correct 35 ms 160444 KB Output is correct
14 Correct 35 ms 160340 KB Output is correct
15 Correct 34 ms 160340 KB Output is correct
16 Correct 34 ms 160348 KB Output is correct
17 Correct 34 ms 160340 KB Output is correct
18 Correct 34 ms 160340 KB Output is correct
19 Correct 34 ms 160340 KB Output is correct
20 Correct 38 ms 160336 KB Output is correct
21 Correct 33 ms 160340 KB Output is correct
22 Correct 35 ms 160336 KB Output is correct
23 Correct 34 ms 160340 KB Output is correct
24 Correct 33 ms 160604 KB Output is correct
25 Correct 84 ms 171344 KB Output is correct
26 Correct 80 ms 171348 KB Output is correct
27 Correct 83 ms 171604 KB Output is correct
28 Correct 84 ms 171600 KB Output is correct
29 Correct 68 ms 171552 KB Output is correct
30 Correct 67 ms 171516 KB Output is correct
31 Correct 38 ms 161620 KB Output is correct
32 Correct 38 ms 161620 KB Output is correct
33 Correct 37 ms 161620 KB Output is correct
34 Correct 37 ms 161620 KB Output is correct
35 Correct 70 ms 163632 KB Output is correct
36 Correct 70 ms 164176 KB Output is correct
37 Correct 83 ms 163920 KB Output is correct
38 Correct 81 ms 164288 KB Output is correct
39 Correct 63 ms 164028 KB Output is correct
40 Correct 63 ms 163668 KB Output is correct
41 Correct 37 ms 160848 KB Output is correct
42 Correct 37 ms 160852 KB Output is correct
43 Correct 71 ms 162896 KB Output is correct
44 Correct 74 ms 162832 KB Output is correct
45 Correct 82 ms 163052 KB Output is correct
46 Correct 80 ms 162384 KB Output is correct
47 Correct 66 ms 162244 KB Output is correct
48 Correct 89 ms 162224 KB Output is correct
49 Correct 39 ms 159656 KB Output is correct
50 Correct 38 ms 159568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 160596 KB Output is correct
2 Correct 34 ms 160604 KB Output is correct
3 Correct 35 ms 160480 KB Output is correct
4 Correct 34 ms 160592 KB Output is correct
5 Correct 35 ms 160604 KB Output is correct
6 Correct 35 ms 160596 KB Output is correct
7 Correct 34 ms 160180 KB Output is correct
8 Correct 34 ms 160340 KB Output is correct
9 Correct 35 ms 160340 KB Output is correct
10 Correct 35 ms 160336 KB Output is correct
11 Correct 34 ms 160344 KB Output is correct
12 Correct 35 ms 160552 KB Output is correct
13 Correct 35 ms 160444 KB Output is correct
14 Correct 35 ms 160340 KB Output is correct
15 Correct 34 ms 160340 KB Output is correct
16 Correct 34 ms 160348 KB Output is correct
17 Correct 34 ms 160340 KB Output is correct
18 Correct 34 ms 160340 KB Output is correct
19 Correct 34 ms 160340 KB Output is correct
20 Correct 38 ms 160336 KB Output is correct
21 Correct 33 ms 160340 KB Output is correct
22 Correct 35 ms 160336 KB Output is correct
23 Correct 34 ms 160340 KB Output is correct
24 Correct 33 ms 160604 KB Output is correct
25 Correct 84 ms 171344 KB Output is correct
26 Correct 80 ms 171348 KB Output is correct
27 Correct 83 ms 171604 KB Output is correct
28 Correct 84 ms 171600 KB Output is correct
29 Correct 68 ms 171552 KB Output is correct
30 Correct 67 ms 171516 KB Output is correct
31 Correct 38 ms 161620 KB Output is correct
32 Correct 38 ms 161620 KB Output is correct
33 Correct 37 ms 161620 KB Output is correct
34 Correct 37 ms 161620 KB Output is correct
35 Correct 70 ms 163632 KB Output is correct
36 Correct 70 ms 164176 KB Output is correct
37 Correct 83 ms 163920 KB Output is correct
38 Correct 81 ms 164288 KB Output is correct
39 Correct 63 ms 164028 KB Output is correct
40 Correct 63 ms 163668 KB Output is correct
41 Correct 37 ms 160848 KB Output is correct
42 Correct 37 ms 160852 KB Output is correct
43 Correct 71 ms 162896 KB Output is correct
44 Correct 74 ms 162832 KB Output is correct
45 Correct 82 ms 163052 KB Output is correct
46 Correct 80 ms 162384 KB Output is correct
47 Correct 66 ms 162244 KB Output is correct
48 Correct 89 ms 162224 KB Output is correct
49 Correct 39 ms 159656 KB Output is correct
50 Correct 38 ms 159568 KB Output is correct
51 Correct 138 ms 188260 KB Output is correct
52 Correct 139 ms 188252 KB Output is correct
53 Correct 168 ms 188548 KB Output is correct
54 Correct 175 ms 188544 KB Output is correct
55 Correct 129 ms 188308 KB Output is correct
56 Correct 123 ms 188392 KB Output is correct
57 Correct 53 ms 165924 KB Output is correct
58 Correct 50 ms 165856 KB Output is correct
59 Correct 49 ms 165892 KB Output is correct
60 Correct 48 ms 165892 KB Output is correct
61 Correct 134 ms 169312 KB Output is correct
62 Correct 130 ms 169808 KB Output is correct
63 Correct 180 ms 169184 KB Output is correct
64 Correct 176 ms 169356 KB Output is correct
65 Correct 113 ms 169816 KB Output is correct
66 Correct 116 ms 169276 KB Output is correct
67 Correct 49 ms 162388 KB Output is correct
68 Correct 47 ms 161876 KB Output is correct
69 Correct 138 ms 166736 KB Output is correct
70 Correct 136 ms 166736 KB Output is correct
71 Correct 170 ms 167252 KB Output is correct
72 Correct 160 ms 166996 KB Output is correct
73 Correct 116 ms 166872 KB Output is correct
74 Correct 114 ms 166736 KB Output is correct
75 Correct 53 ms 161620 KB Output is correct
76 Correct 49 ms 161620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 160596 KB Output is correct
2 Correct 34 ms 160604 KB Output is correct
3 Correct 35 ms 160480 KB Output is correct
4 Correct 34 ms 160592 KB Output is correct
5 Correct 35 ms 160604 KB Output is correct
6 Correct 35 ms 160596 KB Output is correct
7 Correct 34 ms 160180 KB Output is correct
8 Correct 34 ms 160340 KB Output is correct
9 Correct 35 ms 160340 KB Output is correct
10 Correct 35 ms 160336 KB Output is correct
11 Correct 34 ms 160344 KB Output is correct
12 Correct 35 ms 160552 KB Output is correct
13 Correct 35 ms 160444 KB Output is correct
14 Correct 35 ms 160340 KB Output is correct
15 Correct 34 ms 160340 KB Output is correct
16 Correct 34 ms 160348 KB Output is correct
17 Correct 34 ms 160340 KB Output is correct
18 Correct 34 ms 160340 KB Output is correct
19 Correct 34 ms 160340 KB Output is correct
20 Correct 38 ms 160336 KB Output is correct
21 Correct 33 ms 160340 KB Output is correct
22 Correct 35 ms 160336 KB Output is correct
23 Correct 34 ms 160340 KB Output is correct
24 Correct 33 ms 160604 KB Output is correct
25 Correct 36 ms 160448 KB Output is correct
26 Correct 34 ms 160608 KB Output is correct
27 Correct 36 ms 160576 KB Output is correct
28 Correct 35 ms 160592 KB Output is correct
29 Correct 34 ms 160520 KB Output is correct
30 Correct 35 ms 160596 KB Output is correct
31 Correct 35 ms 160596 KB Output is correct
32 Correct 35 ms 160592 KB Output is correct
33 Correct 35 ms 160596 KB Output is correct
34 Correct 37 ms 160636 KB Output is correct
35 Correct 36 ms 160340 KB Output is correct
36 Correct 36 ms 160340 KB Output is correct
37 Correct 35 ms 160348 KB Output is correct
38 Correct 35 ms 160340 KB Output is correct
39 Correct 37 ms 160448 KB Output is correct
40 Correct 34 ms 160348 KB Output is correct
41 Correct 36 ms 160348 KB Output is correct
42 Correct 35 ms 160480 KB Output is correct
43 Correct 35 ms 160352 KB Output is correct
44 Correct 35 ms 160336 KB Output is correct
45 Correct 35 ms 160340 KB Output is correct
46 Correct 35 ms 160340 KB Output is correct
47 Correct 35 ms 160336 KB Output is correct
48 Correct 34 ms 160336 KB Output is correct
49 Correct 36 ms 160336 KB Output is correct
50 Correct 35 ms 160340 KB Output is correct
51 Correct 84 ms 171344 KB Output is correct
52 Correct 80 ms 171348 KB Output is correct
53 Correct 83 ms 171604 KB Output is correct
54 Correct 84 ms 171600 KB Output is correct
55 Correct 68 ms 171552 KB Output is correct
56 Correct 67 ms 171516 KB Output is correct
57 Correct 38 ms 161620 KB Output is correct
58 Correct 38 ms 161620 KB Output is correct
59 Correct 37 ms 161620 KB Output is correct
60 Correct 37 ms 161620 KB Output is correct
61 Correct 70 ms 163632 KB Output is correct
62 Correct 70 ms 164176 KB Output is correct
63 Correct 83 ms 163920 KB Output is correct
64 Correct 81 ms 164288 KB Output is correct
65 Correct 63 ms 164028 KB Output is correct
66 Correct 63 ms 163668 KB Output is correct
67 Correct 37 ms 160848 KB Output is correct
68 Correct 37 ms 160852 KB Output is correct
69 Correct 71 ms 162896 KB Output is correct
70 Correct 74 ms 162832 KB Output is correct
71 Correct 82 ms 163052 KB Output is correct
72 Correct 80 ms 162384 KB Output is correct
73 Correct 66 ms 162244 KB Output is correct
74 Correct 89 ms 162224 KB Output is correct
75 Correct 39 ms 159656 KB Output is correct
76 Correct 38 ms 159568 KB Output is correct
77 Correct 138 ms 188260 KB Output is correct
78 Correct 139 ms 188252 KB Output is correct
79 Correct 168 ms 188548 KB Output is correct
80 Correct 175 ms 188544 KB Output is correct
81 Correct 129 ms 188308 KB Output is correct
82 Correct 123 ms 188392 KB Output is correct
83 Correct 53 ms 165924 KB Output is correct
84 Correct 50 ms 165856 KB Output is correct
85 Correct 49 ms 165892 KB Output is correct
86 Correct 48 ms 165892 KB Output is correct
87 Correct 134 ms 169312 KB Output is correct
88 Correct 130 ms 169808 KB Output is correct
89 Correct 180 ms 169184 KB Output is correct
90 Correct 176 ms 169356 KB Output is correct
91 Correct 113 ms 169816 KB Output is correct
92 Correct 116 ms 169276 KB Output is correct
93 Correct 49 ms 162388 KB Output is correct
94 Correct 47 ms 161876 KB Output is correct
95 Correct 138 ms 166736 KB Output is correct
96 Correct 136 ms 166736 KB Output is correct
97 Correct 170 ms 167252 KB Output is correct
98 Correct 160 ms 166996 KB Output is correct
99 Correct 116 ms 166872 KB Output is correct
100 Correct 114 ms 166736 KB Output is correct
101 Correct 53 ms 161620 KB Output is correct
102 Correct 49 ms 161620 KB Output is correct
103 Correct 197 ms 189008 KB Output is correct
104 Correct 178 ms 188944 KB Output is correct
105 Correct 337 ms 189636 KB Output is correct
106 Correct 346 ms 189520 KB Output is correct
107 Correct 184 ms 189172 KB Output is correct
108 Correct 185 ms 189244 KB Output is correct
109 Correct 63 ms 166052 KB Output is correct
110 Correct 71 ms 166304 KB Output is correct
111 Correct 64 ms 166068 KB Output is correct
112 Correct 63 ms 166480 KB Output is correct
113 Correct 174 ms 171016 KB Output is correct
114 Correct 171 ms 170320 KB Output is correct
115 Correct 293 ms 170836 KB Output is correct
116 Correct 315 ms 171428 KB Output is correct
117 Correct 157 ms 170320 KB Output is correct
118 Correct 166 ms 169808 KB Output is correct
119 Correct 61 ms 162640 KB Output is correct
120 Correct 63 ms 162424 KB Output is correct
121 Correct 173 ms 167504 KB Output is correct
122 Correct 204 ms 167464 KB Output is correct
123 Correct 307 ms 168376 KB Output is correct
124 Correct 315 ms 168148 KB Output is correct
125 Correct 162 ms 167428 KB Output is correct
126 Correct 165 ms 167512 KB Output is correct
127 Correct 64 ms 161804 KB Output is correct
128 Correct 63 ms 161804 KB Output is correct