Submission #1100069

# Submission time Handle Problem Language Result Execution time Memory
1100069 2024-10-12T15:52:50 Z NoMercy Curtains (NOI23_curtains) C++17
100 / 100
733 ms 55872 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int inf = 1e9 + 199;

#define left v + 1
#define right v + 2 * (mid - l)
struct Lazy_Segree {
	struct pi {
		int mn = 0, lazy = 0, mark = 0;
	} emp;
	vector<pi> tree;
	void init (int x) {
		tree.assign (x << 1, emp);
	}

	void push (int v, int l, int r) {
		if (tree[v].mark == 0 || l == r) return;
		int mid = (l + r) >> 1;
		tree[left].mn = max(tree[left].mn, tree[v].lazy);
		tree[right].mn = max(tree[right].mn, tree[v].lazy);
		tree[left].lazy = max(tree[left].lazy, tree[v].lazy);
		tree[right].lazy = max(tree[right].lazy, tree[v].lazy);
		tree[v].mark = tree[v].lazy = 0;
		tree[left].mark = tree[right].mark = 1;
	}
	void update (int v, int l, int r, int ml, int mr, int val) {
		if (l == r || l >= mr || ml >= r) return;
		if (ml <= l && r <= mr) {
			tree[v].mn = max(tree[v].mn, val);
			tree[v].lazy = max(tree[v].lazy, val);
			tree[v].mark = 1;
			return;
		}
		push (v, l, r);
		int mid = (l + r) >> 1;
		update (left, l, mid, ml, mr, val);
		update (right, mid, r, ml, mr, val);
		tree[v].mn = min(tree[left].mn, tree[right].mn);
	}
	int get (int v, int l, int r, int ml, int mr) {
		if (l == r || l >= mr || ml >= r) return inf;
		if (ml <= l && r <= mr) {
			return tree[v].mn;
		}
		push (v, l, r);
		int mid = (l + r) >> 1;
		return min(get (left, l, mid, ml, mr), get (right, mid, r, ml, mr));
	}
};

int32_t main () {

	ios_base::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0); 

	int N, M, Q;
	cin >> N >> M >> Q;
	vector<array<int, 2>> all;
	for (int i = 0;i < M;i ++) {
		int l, r;
		cin >> l >> r;
		all.push_back({l, r});
	}
	vector<array<int, 3>> q;
	for (int i = 0;i < Q;i ++) {
		int l, r;
		cin >> l >> r;
		q.push_back({l, r, i});
	}
	sort(q.begin(), q.end(), [&](array<int, 3> a, array<int, 3> b) {
		return (a[1] < b[1]);
	});
	sort(all.begin(), all.end(), [&](array<int, 2> a, array<int, 2> b) {
		return (a[1] < b[1]);
	});

	Lazy_Segree LS;
	LS.init (N + 1);
	
	string res[Q];
	int ind = 0;
	// cout << "\n";
	for (int i = 0;i < Q;i ++) {
		// cout << q[i][0] << " " << q[i][1] << "\n";
		while (ind < M && all[ind][1] <= q[i][1]) {
			LS.update (1, 1, N + 1, all[ind][0], all[ind][1] + 1, all[ind][0]);
			ind ++;
		}
		if (LS.get (1, 1, N + 1, q[i][0], q[i][1] + 1) >= q[i][0]) {
			res[q[i][2]] = "YES";
		} else {
			res[q[i][2]] = "NO";
		}
	}
	for (int i = 0;i < Q;i ++) {
		cout << res[i] << "\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 472 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 1 ms 524 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 672 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 472 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 1 ms 524 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 672 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 209 ms 27836 KB Output is correct
23 Correct 213 ms 28664 KB Output is correct
24 Correct 236 ms 30660 KB Output is correct
25 Correct 403 ms 39464 KB Output is correct
26 Correct 207 ms 28140 KB Output is correct
27 Correct 389 ms 39608 KB Output is correct
28 Correct 419 ms 39608 KB Output is correct
29 Correct 196 ms 27884 KB Output is correct
30 Correct 152 ms 27252 KB Output is correct
31 Correct 167 ms 28356 KB Output is correct
32 Correct 368 ms 38356 KB Output is correct
33 Correct 163 ms 27384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 149 ms 27168 KB Output is correct
9 Correct 160 ms 28224 KB Output is correct
10 Correct 352 ms 38328 KB Output is correct
11 Correct 175 ms 27380 KB Output is correct
12 Correct 93 ms 10764 KB Output is correct
13 Correct 103 ms 10792 KB Output is correct
14 Correct 77 ms 10636 KB Output is correct
15 Correct 78 ms 10808 KB Output is correct
16 Correct 75 ms 10760 KB Output is correct
17 Correct 73 ms 10692 KB Output is correct
18 Correct 508 ms 53304 KB Output is correct
19 Correct 513 ms 53316 KB Output is correct
20 Correct 397 ms 52920 KB Output is correct
21 Correct 419 ms 53180 KB Output is correct
22 Correct 450 ms 52904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 472 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 1 ms 524 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 672 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 96 ms 8396 KB Output is correct
23 Correct 100 ms 8476 KB Output is correct
24 Correct 158 ms 11204 KB Output is correct
25 Correct 119 ms 11204 KB Output is correct
26 Correct 88 ms 11204 KB Output is correct
27 Correct 94 ms 11148 KB Output is correct
28 Correct 76 ms 9880 KB Output is correct
29 Correct 86 ms 10956 KB Output is correct
30 Correct 110 ms 11212 KB Output is correct
31 Correct 117 ms 11220 KB Output is correct
32 Correct 114 ms 11060 KB Output is correct
33 Correct 89 ms 11212 KB Output is correct
34 Correct 106 ms 11204 KB Output is correct
35 Correct 102 ms 11080 KB Output is correct
36 Correct 120 ms 11212 KB Output is correct
37 Correct 99 ms 10692 KB Output is correct
38 Correct 98 ms 10840 KB Output is correct
39 Correct 75 ms 10700 KB Output is correct
40 Correct 76 ms 10700 KB Output is correct
41 Correct 75 ms 10700 KB Output is correct
42 Correct 73 ms 10700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 472 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 1 ms 524 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 672 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 209 ms 27836 KB Output is correct
23 Correct 213 ms 28664 KB Output is correct
24 Correct 236 ms 30660 KB Output is correct
25 Correct 403 ms 39464 KB Output is correct
26 Correct 207 ms 28140 KB Output is correct
27 Correct 389 ms 39608 KB Output is correct
28 Correct 419 ms 39608 KB Output is correct
29 Correct 196 ms 27884 KB Output is correct
30 Correct 152 ms 27252 KB Output is correct
31 Correct 167 ms 28356 KB Output is correct
32 Correct 368 ms 38356 KB Output is correct
33 Correct 163 ms 27384 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 149 ms 27168 KB Output is correct
42 Correct 160 ms 28224 KB Output is correct
43 Correct 352 ms 38328 KB Output is correct
44 Correct 175 ms 27380 KB Output is correct
45 Correct 93 ms 10764 KB Output is correct
46 Correct 103 ms 10792 KB Output is correct
47 Correct 77 ms 10636 KB Output is correct
48 Correct 78 ms 10808 KB Output is correct
49 Correct 75 ms 10760 KB Output is correct
50 Correct 73 ms 10692 KB Output is correct
51 Correct 508 ms 53304 KB Output is correct
52 Correct 513 ms 53316 KB Output is correct
53 Correct 397 ms 52920 KB Output is correct
54 Correct 419 ms 53180 KB Output is correct
55 Correct 450 ms 52904 KB Output is correct
56 Correct 96 ms 8396 KB Output is correct
57 Correct 100 ms 8476 KB Output is correct
58 Correct 158 ms 11204 KB Output is correct
59 Correct 119 ms 11204 KB Output is correct
60 Correct 88 ms 11204 KB Output is correct
61 Correct 94 ms 11148 KB Output is correct
62 Correct 76 ms 9880 KB Output is correct
63 Correct 86 ms 10956 KB Output is correct
64 Correct 110 ms 11212 KB Output is correct
65 Correct 117 ms 11220 KB Output is correct
66 Correct 114 ms 11060 KB Output is correct
67 Correct 89 ms 11212 KB Output is correct
68 Correct 106 ms 11204 KB Output is correct
69 Correct 102 ms 11080 KB Output is correct
70 Correct 120 ms 11212 KB Output is correct
71 Correct 99 ms 10692 KB Output is correct
72 Correct 98 ms 10840 KB Output is correct
73 Correct 75 ms 10700 KB Output is correct
74 Correct 76 ms 10700 KB Output is correct
75 Correct 75 ms 10700 KB Output is correct
76 Correct 73 ms 10700 KB Output is correct
77 Correct 733 ms 55584 KB Output is correct
78 Correct 612 ms 55848 KB Output is correct
79 Correct 465 ms 55872 KB Output is correct
80 Correct 498 ms 55828 KB Output is correct
81 Correct 536 ms 54684 KB Output is correct
82 Correct 503 ms 55188 KB Output is correct
83 Correct 682 ms 55552 KB Output is correct
84 Correct 716 ms 55480 KB Output is correct
85 Correct 659 ms 55800 KB Output is correct
86 Correct 646 ms 55224 KB Output is correct
87 Correct 613 ms 54456 KB Output is correct
88 Correct 544 ms 55484 KB Output is correct