Submission #966343

# Submission time Handle Problem Language Result Execution time Memory
966343 2024-04-19T17:50:20 Z Acanikolic Curtains (NOI23_curtains) C++14
100 / 100
980 ms 78416 KB
#include <bits/stdc++.h>
			 				 
#define pb push_back 
			
#define F first
		 
#define S second
			 
using namespace std;
			 
const int N = 500000 + 10;
			 
const int mod = 998244353;

const int inf = 1e9;

int res[N],mx[N];
vector<int>segs[N];
vector<pair<int,int>>kveri[N];

int st[N * 4],lazy[N * 4];
bool lzy[N * 4];

void push(int node,int tl,int tr) {
	if(!lzy[node]) return;
	st[node] = max(st[node],lazy[node]);
	if(tl != tr) {
		lazy[node * 2] = max(lazy[node * 2],lazy[node]);
		lazy[node * 2 + 1] = max(lazy[node * 2 + 1],lazy[node]);
		lzy[node * 2] = true;
		lzy[node * 2 + 1] = true;
	}
	lazy[node] = 0;
	lzy[node] = false;
}

void Set(int node,int tl,int tr,int l,int r,int x) {
	push(node,tl,tr);
	if(tl > r || tr < l) return;
	if(tl >= l && tr <= r) {
		lazy[node] = max(lazy[node],x);
		lzy[node] = true;
		push(node,tl,tr);
		return;
	}
	push(node,tl,tr);
	int mid = (tl + tr) / 2;
	Set(node * 2,tl,mid,l,r,x);
	Set(node * 2 + 1,mid + 1,tr,l,r,x);
	st[node] = min(st[node * 2],st[node * 2 + 1]);
}

int get(int node,int tl,int tr,int l,int r) {
	push(node,tl,tr);
	if(tl > r || tr < l) return inf;
	if(tl >= l && tr <= r) return st[node];
	int mid = (tl + tr) / 2;
	return min(get(node * 2,tl,mid,l,r),get(node * 2 + 1,mid + 1,tr,l,r));
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

	int n,m,q;
	cin >> n >> m >> q;
	for(int i = 1; i <= m; i++) {
		int l,r;
		cin >> l >> r;
		segs[r].pb(l);
	}
	for(int i = 1; i <= q; i++) {
		int l,r;
		cin >> l >> r;
		kveri[r].pb({l,i});
	}
	for(int i = 1; i <= n; i++) {
		for(auto X : segs[i]) Set(1,1,n,X,i,X);
		for(auto X : kveri[i]) if(get(1,1,n,X.F,i) >= X.F) res[X.S] = 1;
	}
	for(int i = 1; i <= q; i++) cout << (res[i] == 1 ? "YES\n" : "NO\n");
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 26972 KB Output is correct
2 Correct 6 ms 27096 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 27064 KB Output is correct
5 Correct 6 ms 26968 KB Output is correct
6 Correct 6 ms 27056 KB Output is correct
7 Correct 6 ms 26972 KB Output is correct
8 Correct 6 ms 25032 KB Output is correct
9 Correct 6 ms 26968 KB Output is correct
10 Correct 6 ms 24924 KB Output is correct
11 Correct 6 ms 26972 KB Output is correct
12 Correct 6 ms 26972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 26972 KB Output is correct
2 Correct 6 ms 27096 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 27064 KB Output is correct
5 Correct 6 ms 26968 KB Output is correct
6 Correct 6 ms 27056 KB Output is correct
7 Correct 6 ms 26972 KB Output is correct
8 Correct 6 ms 25032 KB Output is correct
9 Correct 6 ms 26968 KB Output is correct
10 Correct 6 ms 24924 KB Output is correct
11 Correct 6 ms 26972 KB Output is correct
12 Correct 6 ms 26972 KB Output is correct
13 Correct 9 ms 27224 KB Output is correct
14 Correct 8 ms 27228 KB Output is correct
15 Correct 8 ms 27228 KB Output is correct
16 Correct 7 ms 27228 KB Output is correct
17 Correct 7 ms 27300 KB Output is correct
18 Correct 7 ms 27228 KB Output is correct
19 Correct 6 ms 25180 KB Output is correct
20 Correct 7 ms 27224 KB Output is correct
21 Correct 7 ms 27228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 26972 KB Output is correct
2 Correct 6 ms 27096 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 27064 KB Output is correct
5 Correct 6 ms 26968 KB Output is correct
6 Correct 6 ms 27056 KB Output is correct
7 Correct 6 ms 26972 KB Output is correct
8 Correct 6 ms 25032 KB Output is correct
9 Correct 6 ms 26968 KB Output is correct
10 Correct 6 ms 24924 KB Output is correct
11 Correct 6 ms 26972 KB Output is correct
12 Correct 6 ms 26972 KB Output is correct
13 Correct 9 ms 27224 KB Output is correct
14 Correct 8 ms 27228 KB Output is correct
15 Correct 8 ms 27228 KB Output is correct
16 Correct 7 ms 27228 KB Output is correct
17 Correct 7 ms 27300 KB Output is correct
18 Correct 7 ms 27228 KB Output is correct
19 Correct 6 ms 25180 KB Output is correct
20 Correct 7 ms 27224 KB Output is correct
21 Correct 7 ms 27228 KB Output is correct
22 Correct 178 ms 36648 KB Output is correct
23 Correct 202 ms 37464 KB Output is correct
24 Correct 202 ms 37464 KB Output is correct
25 Correct 355 ms 40064 KB Output is correct
26 Correct 175 ms 36688 KB Output is correct
27 Correct 373 ms 40032 KB Output is correct
28 Correct 348 ms 39760 KB Output is correct
29 Correct 150 ms 35920 KB Output is correct
30 Correct 121 ms 37084 KB Output is correct
31 Correct 135 ms 37464 KB Output is correct
32 Correct 295 ms 40092 KB Output is correct
33 Correct 106 ms 37204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 26968 KB Output is correct
2 Correct 6 ms 24924 KB Output is correct
3 Correct 5 ms 27036 KB Output is correct
4 Correct 6 ms 24924 KB Output is correct
5 Correct 9 ms 27100 KB Output is correct
6 Correct 7 ms 27228 KB Output is correct
7 Correct 7 ms 25032 KB Output is correct
8 Correct 100 ms 37016 KB Output is correct
9 Correct 120 ms 37456 KB Output is correct
10 Correct 294 ms 40084 KB Output is correct
11 Correct 110 ms 37204 KB Output is correct
12 Correct 111 ms 34896 KB Output is correct
13 Correct 105 ms 36784 KB Output is correct
14 Correct 82 ms 34456 KB Output is correct
15 Correct 78 ms 36204 KB Output is correct
16 Correct 77 ms 34576 KB Output is correct
17 Correct 84 ms 36432 KB Output is correct
18 Correct 698 ms 75088 KB Output is correct
19 Correct 684 ms 75348 KB Output is correct
20 Correct 508 ms 76100 KB Output is correct
21 Correct 560 ms 72548 KB Output is correct
22 Correct 505 ms 71584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 26972 KB Output is correct
2 Correct 6 ms 27096 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 27064 KB Output is correct
5 Correct 6 ms 26968 KB Output is correct
6 Correct 6 ms 27056 KB Output is correct
7 Correct 6 ms 26972 KB Output is correct
8 Correct 6 ms 25032 KB Output is correct
9 Correct 6 ms 26968 KB Output is correct
10 Correct 6 ms 24924 KB Output is correct
11 Correct 6 ms 26972 KB Output is correct
12 Correct 6 ms 26972 KB Output is correct
13 Correct 9 ms 27224 KB Output is correct
14 Correct 8 ms 27228 KB Output is correct
15 Correct 8 ms 27228 KB Output is correct
16 Correct 7 ms 27228 KB Output is correct
17 Correct 7 ms 27300 KB Output is correct
18 Correct 7 ms 27228 KB Output is correct
19 Correct 6 ms 25180 KB Output is correct
20 Correct 7 ms 27224 KB Output is correct
21 Correct 7 ms 27228 KB Output is correct
22 Correct 105 ms 30032 KB Output is correct
23 Correct 99 ms 30036 KB Output is correct
24 Correct 164 ms 33620 KB Output is correct
25 Correct 135 ms 35920 KB Output is correct
26 Correct 96 ms 37012 KB Output is correct
27 Correct 101 ms 37300 KB Output is correct
28 Correct 78 ms 34888 KB Output is correct
29 Correct 89 ms 36360 KB Output is correct
30 Correct 132 ms 36224 KB Output is correct
31 Correct 131 ms 35860 KB Output is correct
32 Correct 112 ms 36456 KB Output is correct
33 Correct 106 ms 36692 KB Output is correct
34 Correct 133 ms 35536 KB Output is correct
35 Correct 120 ms 35668 KB Output is correct
36 Correct 106 ms 36180 KB Output is correct
37 Correct 110 ms 36656 KB Output is correct
38 Correct 108 ms 36592 KB Output is correct
39 Correct 88 ms 34660 KB Output is correct
40 Correct 81 ms 36176 KB Output is correct
41 Correct 82 ms 34388 KB Output is correct
42 Correct 79 ms 36272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 26972 KB Output is correct
2 Correct 6 ms 27096 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 27064 KB Output is correct
5 Correct 6 ms 26968 KB Output is correct
6 Correct 6 ms 27056 KB Output is correct
7 Correct 6 ms 26972 KB Output is correct
8 Correct 6 ms 25032 KB Output is correct
9 Correct 6 ms 26968 KB Output is correct
10 Correct 6 ms 24924 KB Output is correct
11 Correct 6 ms 26972 KB Output is correct
12 Correct 6 ms 26972 KB Output is correct
13 Correct 9 ms 27224 KB Output is correct
14 Correct 8 ms 27228 KB Output is correct
15 Correct 8 ms 27228 KB Output is correct
16 Correct 7 ms 27228 KB Output is correct
17 Correct 7 ms 27300 KB Output is correct
18 Correct 7 ms 27228 KB Output is correct
19 Correct 6 ms 25180 KB Output is correct
20 Correct 7 ms 27224 KB Output is correct
21 Correct 7 ms 27228 KB Output is correct
22 Correct 178 ms 36648 KB Output is correct
23 Correct 202 ms 37464 KB Output is correct
24 Correct 202 ms 37464 KB Output is correct
25 Correct 355 ms 40064 KB Output is correct
26 Correct 175 ms 36688 KB Output is correct
27 Correct 373 ms 40032 KB Output is correct
28 Correct 348 ms 39760 KB Output is correct
29 Correct 150 ms 35920 KB Output is correct
30 Correct 121 ms 37084 KB Output is correct
31 Correct 135 ms 37464 KB Output is correct
32 Correct 295 ms 40092 KB Output is correct
33 Correct 106 ms 37204 KB Output is correct
34 Correct 6 ms 26968 KB Output is correct
35 Correct 6 ms 24924 KB Output is correct
36 Correct 5 ms 27036 KB Output is correct
37 Correct 6 ms 24924 KB Output is correct
38 Correct 9 ms 27100 KB Output is correct
39 Correct 7 ms 27228 KB Output is correct
40 Correct 7 ms 25032 KB Output is correct
41 Correct 100 ms 37016 KB Output is correct
42 Correct 120 ms 37456 KB Output is correct
43 Correct 294 ms 40084 KB Output is correct
44 Correct 110 ms 37204 KB Output is correct
45 Correct 111 ms 34896 KB Output is correct
46 Correct 105 ms 36784 KB Output is correct
47 Correct 82 ms 34456 KB Output is correct
48 Correct 78 ms 36204 KB Output is correct
49 Correct 77 ms 34576 KB Output is correct
50 Correct 84 ms 36432 KB Output is correct
51 Correct 698 ms 75088 KB Output is correct
52 Correct 684 ms 75348 KB Output is correct
53 Correct 508 ms 76100 KB Output is correct
54 Correct 560 ms 72548 KB Output is correct
55 Correct 505 ms 71584 KB Output is correct
56 Correct 105 ms 30032 KB Output is correct
57 Correct 99 ms 30036 KB Output is correct
58 Correct 164 ms 33620 KB Output is correct
59 Correct 135 ms 35920 KB Output is correct
60 Correct 96 ms 37012 KB Output is correct
61 Correct 101 ms 37300 KB Output is correct
62 Correct 78 ms 34888 KB Output is correct
63 Correct 89 ms 36360 KB Output is correct
64 Correct 132 ms 36224 KB Output is correct
65 Correct 131 ms 35860 KB Output is correct
66 Correct 112 ms 36456 KB Output is correct
67 Correct 106 ms 36692 KB Output is correct
68 Correct 133 ms 35536 KB Output is correct
69 Correct 120 ms 35668 KB Output is correct
70 Correct 106 ms 36180 KB Output is correct
71 Correct 110 ms 36656 KB Output is correct
72 Correct 108 ms 36592 KB Output is correct
73 Correct 88 ms 34660 KB Output is correct
74 Correct 81 ms 36176 KB Output is correct
75 Correct 82 ms 34388 KB Output is correct
76 Correct 79 ms 36272 KB Output is correct
77 Correct 889 ms 73044 KB Output is correct
78 Correct 942 ms 72016 KB Output is correct
79 Correct 630 ms 78416 KB Output is correct
80 Correct 752 ms 78064 KB Output is correct
81 Correct 653 ms 75852 KB Output is correct
82 Correct 686 ms 77188 KB Output is correct
83 Correct 893 ms 73128 KB Output is correct
84 Correct 980 ms 71668 KB Output is correct
85 Correct 923 ms 74708 KB Output is correct
86 Correct 862 ms 71440 KB Output is correct
87 Correct 810 ms 71144 KB Output is correct
88 Correct 765 ms 77664 KB Output is correct