/* author : bo may can 5 */
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define endl '\n'
#define file(name) \
if(fopen(name".inp", "r")) \
freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
const int MAX = 5e5 + 5;
int n, m, q;
vector <pair <int, int>> queries[MAX];
vector <int> events[MAX];
int ans[MAX], it[MAX << 2], lazy[MAX << 2];
void down(int idx) {
if(lazy[idx] == 0) return;
for (int i = 2 * idx; i <= 2 * idx + 1; ++i) {
it[i] = max(it[i], lazy[idx]);
lazy[i] = max(lazy[i], lazy[idx]);
}
lazy[idx] = 0;
}
void update(int idx, int l, int r, int u, int v, int val) {
if(l > v || r < u) return;
if(l >= u && r <= v) {
it[idx] = max(it[idx], val);
lazy[idx] = max(lazy[idx], val);
return;
}
down(idx);
int mid = l + r >> 1;
update(idx << 1, l, mid, u, v, val);
update(idx << 1 | 1, mid + 1, r, u, v, val);
it[idx] = min(it[idx << 1], it[idx << 1 | 1]);
}
int get(int idx, int l, int r, int u, int v) {
if(l > v || r < u) return 1e9;
if(l >= u && r <= v) return it[idx];
down(idx);
int mid = l + r >> 1;
return min(get(idx << 1, l, mid, u, v), get(idx << 1 | 1, mid + 1, r, u, v));
}
void you_make_it(void) {
cin >> n >> m >> q;
for (int i = 1; i <= m; ++i) {
int l, r; cin >> l >> r;
events[r].emplace_back(l);
}
for (int i = 1; i <= q; ++i) {
int l, r; cin >> l >> r;
queries[r].emplace_back(l, i);
}
for (int r = 1; r <= n; ++r) {
for (auto l : events[r]) update(1, 1, n, l, r, l);
for (auto [l, i] : queries[r]) {
if(get(1, 1, n, l, r) >= l) ans[i] = 1;
}
}
for (int i = 1; i <= q; ++i) cout << (ans[i] ? "YES\n" : "NO\n");
}
signed main() {
#ifdef LOCAL
freopen("TASK.inp", "r", stdin);
freopen("TASK.out", "w", stdout);
#endif
file("curtains");
auto start_time = chrono::steady_clock::now();
cin.tie(0), cout.tie(0) -> sync_with_stdio(0);
you_make_it();
auto end_time = chrono::steady_clock::now();
cerr << "\nExecution time : " << chrono::duration_cast <chrono::milliseconds> (end_time - start_time).count() << "[ms]" << endl;
return (0 ^ 0);
}
// Dream it. Wish it. Do it.
Compilation message
curtains.cpp: In function 'void update(int, int, int, int, int, int)':
curtains.cpp:41:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
41 | int mid = l + r >> 1;
| ~~^~~
curtains.cpp: In function 'int get(int, int, int, int, int)':
curtains.cpp:55:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
55 | int mid = l + r >> 1;
| ~~^~~
curtains.cpp: In function 'int main()':
curtains.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:86:5: note: in expansion of macro 'file'
86 | file("curtains");
| ^~~~
curtains.cpp:12:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:86:5: note: in expansion of macro 'file'
86 | file("curtains");
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
26968 KB |
Output is correct |
2 |
Correct |
6 ms |
26972 KB |
Output is correct |
3 |
Correct |
6 ms |
26972 KB |
Output is correct |
4 |
Correct |
6 ms |
26956 KB |
Output is correct |
5 |
Correct |
6 ms |
26972 KB |
Output is correct |
6 |
Correct |
7 ms |
26972 KB |
Output is correct |
7 |
Correct |
6 ms |
26972 KB |
Output is correct |
8 |
Correct |
6 ms |
24924 KB |
Output is correct |
9 |
Correct |
6 ms |
26972 KB |
Output is correct |
10 |
Correct |
6 ms |
24924 KB |
Output is correct |
11 |
Correct |
6 ms |
26960 KB |
Output is correct |
12 |
Correct |
6 ms |
26968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
26968 KB |
Output is correct |
2 |
Correct |
6 ms |
26972 KB |
Output is correct |
3 |
Correct |
6 ms |
26972 KB |
Output is correct |
4 |
Correct |
6 ms |
26956 KB |
Output is correct |
5 |
Correct |
6 ms |
26972 KB |
Output is correct |
6 |
Correct |
7 ms |
26972 KB |
Output is correct |
7 |
Correct |
6 ms |
26972 KB |
Output is correct |
8 |
Correct |
6 ms |
24924 KB |
Output is correct |
9 |
Correct |
6 ms |
26972 KB |
Output is correct |
10 |
Correct |
6 ms |
24924 KB |
Output is correct |
11 |
Correct |
6 ms |
26960 KB |
Output is correct |
12 |
Correct |
6 ms |
26968 KB |
Output is correct |
13 |
Correct |
8 ms |
27224 KB |
Output is correct |
14 |
Correct |
7 ms |
26968 KB |
Output is correct |
15 |
Correct |
8 ms |
26968 KB |
Output is correct |
16 |
Correct |
9 ms |
26972 KB |
Output is correct |
17 |
Correct |
9 ms |
26972 KB |
Output is correct |
18 |
Correct |
7 ms |
26972 KB |
Output is correct |
19 |
Correct |
7 ms |
24924 KB |
Output is correct |
20 |
Correct |
7 ms |
26968 KB |
Output is correct |
21 |
Correct |
7 ms |
26972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
26968 KB |
Output is correct |
2 |
Correct |
6 ms |
26972 KB |
Output is correct |
3 |
Correct |
6 ms |
26972 KB |
Output is correct |
4 |
Correct |
6 ms |
26956 KB |
Output is correct |
5 |
Correct |
6 ms |
26972 KB |
Output is correct |
6 |
Correct |
7 ms |
26972 KB |
Output is correct |
7 |
Correct |
6 ms |
26972 KB |
Output is correct |
8 |
Correct |
6 ms |
24924 KB |
Output is correct |
9 |
Correct |
6 ms |
26972 KB |
Output is correct |
10 |
Correct |
6 ms |
24924 KB |
Output is correct |
11 |
Correct |
6 ms |
26960 KB |
Output is correct |
12 |
Correct |
6 ms |
26968 KB |
Output is correct |
13 |
Correct |
8 ms |
27224 KB |
Output is correct |
14 |
Correct |
7 ms |
26968 KB |
Output is correct |
15 |
Correct |
8 ms |
26968 KB |
Output is correct |
16 |
Correct |
9 ms |
26972 KB |
Output is correct |
17 |
Correct |
9 ms |
26972 KB |
Output is correct |
18 |
Correct |
7 ms |
26972 KB |
Output is correct |
19 |
Correct |
7 ms |
24924 KB |
Output is correct |
20 |
Correct |
7 ms |
26968 KB |
Output is correct |
21 |
Correct |
7 ms |
26972 KB |
Output is correct |
22 |
Correct |
160 ms |
34764 KB |
Output is correct |
23 |
Correct |
169 ms |
38992 KB |
Output is correct |
24 |
Correct |
203 ms |
40016 KB |
Output is correct |
25 |
Correct |
352 ms |
44880 KB |
Output is correct |
26 |
Correct |
194 ms |
38756 KB |
Output is correct |
27 |
Correct |
329 ms |
45076 KB |
Output is correct |
28 |
Correct |
327 ms |
45000 KB |
Output is correct |
29 |
Correct |
151 ms |
37712 KB |
Output is correct |
30 |
Correct |
110 ms |
38008 KB |
Output is correct |
31 |
Correct |
121 ms |
38564 KB |
Output is correct |
32 |
Correct |
260 ms |
44372 KB |
Output is correct |
33 |
Correct |
104 ms |
38080 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
26972 KB |
Output is correct |
2 |
Correct |
6 ms |
24908 KB |
Output is correct |
3 |
Correct |
6 ms |
26972 KB |
Output is correct |
4 |
Correct |
6 ms |
24924 KB |
Output is correct |
5 |
Correct |
8 ms |
26972 KB |
Output is correct |
6 |
Correct |
7 ms |
26968 KB |
Output is correct |
7 |
Correct |
8 ms |
24924 KB |
Output is correct |
8 |
Correct |
130 ms |
35164 KB |
Output is correct |
9 |
Correct |
150 ms |
38604 KB |
Output is correct |
10 |
Correct |
266 ms |
44368 KB |
Output is correct |
11 |
Correct |
104 ms |
37972 KB |
Output is correct |
12 |
Correct |
96 ms |
36136 KB |
Output is correct |
13 |
Correct |
96 ms |
35920 KB |
Output is correct |
14 |
Correct |
81 ms |
34132 KB |
Output is correct |
15 |
Correct |
76 ms |
35668 KB |
Output is correct |
16 |
Correct |
92 ms |
33972 KB |
Output is correct |
17 |
Correct |
82 ms |
35668 KB |
Output is correct |
18 |
Correct |
683 ms |
69808 KB |
Output is correct |
19 |
Correct |
652 ms |
70076 KB |
Output is correct |
20 |
Correct |
536 ms |
71764 KB |
Output is correct |
21 |
Correct |
500 ms |
68944 KB |
Output is correct |
22 |
Correct |
517 ms |
70360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
26968 KB |
Output is correct |
2 |
Correct |
6 ms |
26972 KB |
Output is correct |
3 |
Correct |
6 ms |
26972 KB |
Output is correct |
4 |
Correct |
6 ms |
26956 KB |
Output is correct |
5 |
Correct |
6 ms |
26972 KB |
Output is correct |
6 |
Correct |
7 ms |
26972 KB |
Output is correct |
7 |
Correct |
6 ms |
26972 KB |
Output is correct |
8 |
Correct |
6 ms |
24924 KB |
Output is correct |
9 |
Correct |
6 ms |
26972 KB |
Output is correct |
10 |
Correct |
6 ms |
24924 KB |
Output is correct |
11 |
Correct |
6 ms |
26960 KB |
Output is correct |
12 |
Correct |
6 ms |
26968 KB |
Output is correct |
13 |
Correct |
8 ms |
27224 KB |
Output is correct |
14 |
Correct |
7 ms |
26968 KB |
Output is correct |
15 |
Correct |
8 ms |
26968 KB |
Output is correct |
16 |
Correct |
9 ms |
26972 KB |
Output is correct |
17 |
Correct |
9 ms |
26972 KB |
Output is correct |
18 |
Correct |
7 ms |
26972 KB |
Output is correct |
19 |
Correct |
7 ms |
24924 KB |
Output is correct |
20 |
Correct |
7 ms |
26968 KB |
Output is correct |
21 |
Correct |
7 ms |
26972 KB |
Output is correct |
22 |
Correct |
91 ms |
29780 KB |
Output is correct |
23 |
Correct |
90 ms |
29604 KB |
Output is correct |
24 |
Correct |
116 ms |
33108 KB |
Output is correct |
25 |
Correct |
117 ms |
33104 KB |
Output is correct |
26 |
Correct |
92 ms |
34084 KB |
Output is correct |
27 |
Correct |
95 ms |
34384 KB |
Output is correct |
28 |
Correct |
76 ms |
32596 KB |
Output is correct |
29 |
Correct |
92 ms |
33616 KB |
Output is correct |
30 |
Correct |
118 ms |
33112 KB |
Output is correct |
31 |
Correct |
124 ms |
33028 KB |
Output is correct |
32 |
Correct |
102 ms |
33524 KB |
Output is correct |
33 |
Correct |
98 ms |
33884 KB |
Output is correct |
34 |
Correct |
106 ms |
32592 KB |
Output is correct |
35 |
Correct |
110 ms |
32928 KB |
Output is correct |
36 |
Correct |
110 ms |
33628 KB |
Output is correct |
37 |
Correct |
96 ms |
34124 KB |
Output is correct |
38 |
Correct |
98 ms |
34128 KB |
Output is correct |
39 |
Correct |
74 ms |
32336 KB |
Output is correct |
40 |
Correct |
88 ms |
34020 KB |
Output is correct |
41 |
Correct |
78 ms |
32084 KB |
Output is correct |
42 |
Correct |
81 ms |
33876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
26968 KB |
Output is correct |
2 |
Correct |
6 ms |
26972 KB |
Output is correct |
3 |
Correct |
6 ms |
26972 KB |
Output is correct |
4 |
Correct |
6 ms |
26956 KB |
Output is correct |
5 |
Correct |
6 ms |
26972 KB |
Output is correct |
6 |
Correct |
7 ms |
26972 KB |
Output is correct |
7 |
Correct |
6 ms |
26972 KB |
Output is correct |
8 |
Correct |
6 ms |
24924 KB |
Output is correct |
9 |
Correct |
6 ms |
26972 KB |
Output is correct |
10 |
Correct |
6 ms |
24924 KB |
Output is correct |
11 |
Correct |
6 ms |
26960 KB |
Output is correct |
12 |
Correct |
6 ms |
26968 KB |
Output is correct |
13 |
Correct |
8 ms |
27224 KB |
Output is correct |
14 |
Correct |
7 ms |
26968 KB |
Output is correct |
15 |
Correct |
8 ms |
26968 KB |
Output is correct |
16 |
Correct |
9 ms |
26972 KB |
Output is correct |
17 |
Correct |
9 ms |
26972 KB |
Output is correct |
18 |
Correct |
7 ms |
26972 KB |
Output is correct |
19 |
Correct |
7 ms |
24924 KB |
Output is correct |
20 |
Correct |
7 ms |
26968 KB |
Output is correct |
21 |
Correct |
7 ms |
26972 KB |
Output is correct |
22 |
Correct |
160 ms |
34764 KB |
Output is correct |
23 |
Correct |
169 ms |
38992 KB |
Output is correct |
24 |
Correct |
203 ms |
40016 KB |
Output is correct |
25 |
Correct |
352 ms |
44880 KB |
Output is correct |
26 |
Correct |
194 ms |
38756 KB |
Output is correct |
27 |
Correct |
329 ms |
45076 KB |
Output is correct |
28 |
Correct |
327 ms |
45000 KB |
Output is correct |
29 |
Correct |
151 ms |
37712 KB |
Output is correct |
30 |
Correct |
110 ms |
38008 KB |
Output is correct |
31 |
Correct |
121 ms |
38564 KB |
Output is correct |
32 |
Correct |
260 ms |
44372 KB |
Output is correct |
33 |
Correct |
104 ms |
38080 KB |
Output is correct |
34 |
Correct |
7 ms |
26972 KB |
Output is correct |
35 |
Correct |
6 ms |
24908 KB |
Output is correct |
36 |
Correct |
6 ms |
26972 KB |
Output is correct |
37 |
Correct |
6 ms |
24924 KB |
Output is correct |
38 |
Correct |
8 ms |
26972 KB |
Output is correct |
39 |
Correct |
7 ms |
26968 KB |
Output is correct |
40 |
Correct |
8 ms |
24924 KB |
Output is correct |
41 |
Correct |
130 ms |
35164 KB |
Output is correct |
42 |
Correct |
150 ms |
38604 KB |
Output is correct |
43 |
Correct |
266 ms |
44368 KB |
Output is correct |
44 |
Correct |
104 ms |
37972 KB |
Output is correct |
45 |
Correct |
96 ms |
36136 KB |
Output is correct |
46 |
Correct |
96 ms |
35920 KB |
Output is correct |
47 |
Correct |
81 ms |
34132 KB |
Output is correct |
48 |
Correct |
76 ms |
35668 KB |
Output is correct |
49 |
Correct |
92 ms |
33972 KB |
Output is correct |
50 |
Correct |
82 ms |
35668 KB |
Output is correct |
51 |
Correct |
683 ms |
69808 KB |
Output is correct |
52 |
Correct |
652 ms |
70076 KB |
Output is correct |
53 |
Correct |
536 ms |
71764 KB |
Output is correct |
54 |
Correct |
500 ms |
68944 KB |
Output is correct |
55 |
Correct |
517 ms |
70360 KB |
Output is correct |
56 |
Correct |
91 ms |
29780 KB |
Output is correct |
57 |
Correct |
90 ms |
29604 KB |
Output is correct |
58 |
Correct |
116 ms |
33108 KB |
Output is correct |
59 |
Correct |
117 ms |
33104 KB |
Output is correct |
60 |
Correct |
92 ms |
34084 KB |
Output is correct |
61 |
Correct |
95 ms |
34384 KB |
Output is correct |
62 |
Correct |
76 ms |
32596 KB |
Output is correct |
63 |
Correct |
92 ms |
33616 KB |
Output is correct |
64 |
Correct |
118 ms |
33112 KB |
Output is correct |
65 |
Correct |
124 ms |
33028 KB |
Output is correct |
66 |
Correct |
102 ms |
33524 KB |
Output is correct |
67 |
Correct |
98 ms |
33884 KB |
Output is correct |
68 |
Correct |
106 ms |
32592 KB |
Output is correct |
69 |
Correct |
110 ms |
32928 KB |
Output is correct |
70 |
Correct |
110 ms |
33628 KB |
Output is correct |
71 |
Correct |
96 ms |
34124 KB |
Output is correct |
72 |
Correct |
98 ms |
34128 KB |
Output is correct |
73 |
Correct |
74 ms |
32336 KB |
Output is correct |
74 |
Correct |
88 ms |
34020 KB |
Output is correct |
75 |
Correct |
78 ms |
32084 KB |
Output is correct |
76 |
Correct |
81 ms |
33876 KB |
Output is correct |
77 |
Correct |
855 ms |
67548 KB |
Output is correct |
78 |
Correct |
828 ms |
65772 KB |
Output is correct |
79 |
Correct |
676 ms |
73184 KB |
Output is correct |
80 |
Correct |
713 ms |
72500 KB |
Output is correct |
81 |
Correct |
648 ms |
70588 KB |
Output is correct |
82 |
Correct |
618 ms |
72016 KB |
Output is correct |
83 |
Correct |
739 ms |
67412 KB |
Output is correct |
84 |
Correct |
763 ms |
62548 KB |
Output is correct |
85 |
Correct |
728 ms |
66076 KB |
Output is correct |
86 |
Correct |
684 ms |
62344 KB |
Output is correct |
87 |
Correct |
630 ms |
62596 KB |
Output is correct |
88 |
Correct |
617 ms |
68676 KB |
Output is correct |