#include<bits/stdc++.h>
#define lsb(x) (x &(-x))
using namespace std;
using pii = pair<int, int>;
const int N = 5e5 + 5;
int n, m, q, x, y, segm[N * 4], lz[N * 4];
void push (int l, int r, int idx) {
segm[idx] = max(segm[idx], lz[idx]);
if (l < r) {
lz[idx * 2 + 1] = max(lz[idx * 2 + 1], lz[idx]);
lz[idx * 2 + 2] = max(lz[idx * 2 + 2], lz[idx]);
}
lz[idx] = 0;
}
void upd (int l, int r, int idx, int tl, int tr, int val) {
push(l, r, idx);
if (l > tr || r < tl) return;
if (l >= tl && r <= tr) {
lz[idx] = max(lz[idx], val);
push(l, r, idx);
return;
}
int mid = (l + r) >> 1;
upd(l, mid, idx * 2 + 1, tl, tr, val);
upd(mid + 1, r, idx * 2 + 2, tl, tr, val);
segm[idx] = min(segm[idx * 2 + 1], segm[idx * 2 + 2]);
}
int qr (int l, int r, int idx, int tl, int tr) {
push(l, r, idx);
if (l > tr || r < tl) return 1e9;
if (l >= tl && r <= tr) return segm[idx];
int mid = (l + r) >> 1;
return min(qr(l, mid, idx * 2 + 1, tl, tr), qr(mid + 1, r, idx * 2 + 2, tl, tr));
}
int main() {
scanf("%d %d %d", &n, &m, &q);
vector<vector<int>> add(n + 5, vector<int>());
vector<vector<pii>> cq(n + 5, vector<pii>());
vector<int> ans(q);
for (int i = 0; i < m; i++) {
scanf("%d %d", &x, &y);
add[y].emplace_back(x);
}
for (int i = 0; i < q; i++) {
scanf("%d %d", &x, &y);
cq[y].emplace_back(x, i);
}
for (int i = 1; i <= n; i++) {
for (auto &e: add[i]) upd(1, n, 0, e, i, e);
for (auto &[x, y]: cq[i]) ans[y] = (qr(1, n, 0, x, i) >= x);
}
for (auto &e: ans) printf("%s\n", e ? "YES" : "NO");
}
Compilation message
curtains.cpp: In function 'int main()':
curtains.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | scanf("%d %d %d", &n, &m, &q);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | scanf("%d %d", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~
curtains.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
51 | scanf("%d %d", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
13 |
Correct |
3 ms |
592 KB |
Output is correct |
14 |
Correct |
3 ms |
592 KB |
Output is correct |
15 |
Correct |
4 ms |
592 KB |
Output is correct |
16 |
Correct |
4 ms |
592 KB |
Output is correct |
17 |
Correct |
3 ms |
592 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
592 KB |
Output is correct |
21 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
13 |
Correct |
3 ms |
592 KB |
Output is correct |
14 |
Correct |
3 ms |
592 KB |
Output is correct |
15 |
Correct |
4 ms |
592 KB |
Output is correct |
16 |
Correct |
4 ms |
592 KB |
Output is correct |
17 |
Correct |
3 ms |
592 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
592 KB |
Output is correct |
21 |
Correct |
3 ms |
760 KB |
Output is correct |
22 |
Correct |
214 ms |
13780 KB |
Output is correct |
23 |
Correct |
224 ms |
13128 KB |
Output is correct |
24 |
Correct |
265 ms |
11260 KB |
Output is correct |
25 |
Correct |
404 ms |
17992 KB |
Output is correct |
26 |
Correct |
202 ms |
10376 KB |
Output is correct |
27 |
Correct |
384 ms |
13648 KB |
Output is correct |
28 |
Correct |
387 ms |
13384 KB |
Output is correct |
29 |
Correct |
192 ms |
11848 KB |
Output is correct |
30 |
Correct |
147 ms |
12376 KB |
Output is correct |
31 |
Correct |
155 ms |
12992 KB |
Output is correct |
32 |
Correct |
343 ms |
13720 KB |
Output is correct |
33 |
Correct |
154 ms |
12624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
592 KB |
Output is correct |
6 |
Correct |
3 ms |
592 KB |
Output is correct |
7 |
Correct |
3 ms |
764 KB |
Output is correct |
8 |
Correct |
144 ms |
11984 KB |
Output is correct |
9 |
Correct |
171 ms |
11080 KB |
Output is correct |
10 |
Correct |
344 ms |
15784 KB |
Output is correct |
11 |
Correct |
163 ms |
10824 KB |
Output is correct |
12 |
Correct |
136 ms |
12616 KB |
Output is correct |
13 |
Correct |
130 ms |
14068 KB |
Output is correct |
14 |
Correct |
89 ms |
12836 KB |
Output is correct |
15 |
Correct |
88 ms |
12360 KB |
Output is correct |
16 |
Correct |
96 ms |
12876 KB |
Output is correct |
17 |
Correct |
103 ms |
12472 KB |
Output is correct |
18 |
Correct |
851 ms |
60504 KB |
Output is correct |
19 |
Correct |
825 ms |
70112 KB |
Output is correct |
20 |
Correct |
606 ms |
61260 KB |
Output is correct |
21 |
Correct |
569 ms |
60332 KB |
Output is correct |
22 |
Correct |
576 ms |
64580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
13 |
Correct |
3 ms |
592 KB |
Output is correct |
14 |
Correct |
3 ms |
592 KB |
Output is correct |
15 |
Correct |
4 ms |
592 KB |
Output is correct |
16 |
Correct |
4 ms |
592 KB |
Output is correct |
17 |
Correct |
3 ms |
592 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
592 KB |
Output is correct |
21 |
Correct |
3 ms |
760 KB |
Output is correct |
22 |
Correct |
99 ms |
3912 KB |
Output is correct |
23 |
Correct |
108 ms |
5960 KB |
Output is correct |
24 |
Correct |
132 ms |
13864 KB |
Output is correct |
25 |
Correct |
127 ms |
11476 KB |
Output is correct |
26 |
Correct |
108 ms |
14512 KB |
Output is correct |
27 |
Correct |
115 ms |
14408 KB |
Output is correct |
28 |
Correct |
96 ms |
12360 KB |
Output is correct |
29 |
Correct |
113 ms |
12360 KB |
Output is correct |
30 |
Correct |
131 ms |
12748 KB |
Output is correct |
31 |
Correct |
134 ms |
13904 KB |
Output is correct |
32 |
Correct |
124 ms |
12104 KB |
Output is correct |
33 |
Correct |
117 ms |
12424 KB |
Output is correct |
34 |
Correct |
135 ms |
11080 KB |
Output is correct |
35 |
Correct |
132 ms |
11408 KB |
Output is correct |
36 |
Correct |
128 ms |
12104 KB |
Output is correct |
37 |
Correct |
132 ms |
12872 KB |
Output is correct |
38 |
Correct |
128 ms |
14104 KB |
Output is correct |
39 |
Correct |
102 ms |
14152 KB |
Output is correct |
40 |
Correct |
97 ms |
13640 KB |
Output is correct |
41 |
Correct |
90 ms |
12872 KB |
Output is correct |
42 |
Correct |
112 ms |
13640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
13 |
Correct |
3 ms |
592 KB |
Output is correct |
14 |
Correct |
3 ms |
592 KB |
Output is correct |
15 |
Correct |
4 ms |
592 KB |
Output is correct |
16 |
Correct |
4 ms |
592 KB |
Output is correct |
17 |
Correct |
3 ms |
592 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
592 KB |
Output is correct |
21 |
Correct |
3 ms |
760 KB |
Output is correct |
22 |
Correct |
214 ms |
13780 KB |
Output is correct |
23 |
Correct |
224 ms |
13128 KB |
Output is correct |
24 |
Correct |
265 ms |
11260 KB |
Output is correct |
25 |
Correct |
404 ms |
17992 KB |
Output is correct |
26 |
Correct |
202 ms |
10376 KB |
Output is correct |
27 |
Correct |
384 ms |
13648 KB |
Output is correct |
28 |
Correct |
387 ms |
13384 KB |
Output is correct |
29 |
Correct |
192 ms |
11848 KB |
Output is correct |
30 |
Correct |
147 ms |
12376 KB |
Output is correct |
31 |
Correct |
155 ms |
12992 KB |
Output is correct |
32 |
Correct |
343 ms |
13720 KB |
Output is correct |
33 |
Correct |
154 ms |
12624 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Correct |
1 ms |
336 KB |
Output is correct |
38 |
Correct |
2 ms |
592 KB |
Output is correct |
39 |
Correct |
3 ms |
592 KB |
Output is correct |
40 |
Correct |
3 ms |
764 KB |
Output is correct |
41 |
Correct |
144 ms |
11984 KB |
Output is correct |
42 |
Correct |
171 ms |
11080 KB |
Output is correct |
43 |
Correct |
344 ms |
15784 KB |
Output is correct |
44 |
Correct |
163 ms |
10824 KB |
Output is correct |
45 |
Correct |
136 ms |
12616 KB |
Output is correct |
46 |
Correct |
130 ms |
14068 KB |
Output is correct |
47 |
Correct |
89 ms |
12836 KB |
Output is correct |
48 |
Correct |
88 ms |
12360 KB |
Output is correct |
49 |
Correct |
96 ms |
12876 KB |
Output is correct |
50 |
Correct |
103 ms |
12472 KB |
Output is correct |
51 |
Correct |
851 ms |
60504 KB |
Output is correct |
52 |
Correct |
825 ms |
70112 KB |
Output is correct |
53 |
Correct |
606 ms |
61260 KB |
Output is correct |
54 |
Correct |
569 ms |
60332 KB |
Output is correct |
55 |
Correct |
576 ms |
64580 KB |
Output is correct |
56 |
Correct |
99 ms |
3912 KB |
Output is correct |
57 |
Correct |
108 ms |
5960 KB |
Output is correct |
58 |
Correct |
132 ms |
13864 KB |
Output is correct |
59 |
Correct |
127 ms |
11476 KB |
Output is correct |
60 |
Correct |
108 ms |
14512 KB |
Output is correct |
61 |
Correct |
115 ms |
14408 KB |
Output is correct |
62 |
Correct |
96 ms |
12360 KB |
Output is correct |
63 |
Correct |
113 ms |
12360 KB |
Output is correct |
64 |
Correct |
131 ms |
12748 KB |
Output is correct |
65 |
Correct |
134 ms |
13904 KB |
Output is correct |
66 |
Correct |
124 ms |
12104 KB |
Output is correct |
67 |
Correct |
117 ms |
12424 KB |
Output is correct |
68 |
Correct |
135 ms |
11080 KB |
Output is correct |
69 |
Correct |
132 ms |
11408 KB |
Output is correct |
70 |
Correct |
128 ms |
12104 KB |
Output is correct |
71 |
Correct |
132 ms |
12872 KB |
Output is correct |
72 |
Correct |
128 ms |
14104 KB |
Output is correct |
73 |
Correct |
102 ms |
14152 KB |
Output is correct |
74 |
Correct |
97 ms |
13640 KB |
Output is correct |
75 |
Correct |
90 ms |
12872 KB |
Output is correct |
76 |
Correct |
112 ms |
13640 KB |
Output is correct |
77 |
Correct |
1004 ms |
61480 KB |
Output is correct |
78 |
Correct |
999 ms |
54600 KB |
Output is correct |
79 |
Correct |
814 ms |
72776 KB |
Output is correct |
80 |
Correct |
720 ms |
61512 KB |
Output is correct |
81 |
Correct |
732 ms |
65864 KB |
Output is correct |
82 |
Correct |
746 ms |
71744 KB |
Output is correct |
83 |
Correct |
951 ms |
54708 KB |
Output is correct |
84 |
Correct |
1016 ms |
61512 KB |
Output is correct |
85 |
Correct |
896 ms |
63236 KB |
Output is correct |
86 |
Correct |
880 ms |
52868 KB |
Output is correct |
87 |
Correct |
913 ms |
53288 KB |
Output is correct |
88 |
Correct |
866 ms |
59208 KB |
Output is correct |