#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct segTree{
pair<int, int> tree[1<<20];
pair<int, int> merge(pair<int, int> a, pair<int, int> b){
if(!a.second) return b;
if(!b.second) return a;
if(a.second + 1 < b.first) return b;
return make_pair(a.first, max(a.second, b.second));
}
void update(int i, int l, int r, int x, pair<int, int> p){
if(l==r){
tree[i] = p;
return;
}
int m = (l+r)>>1;
if(x<=m) update(i*2, l, m, x, p);
else update(i*2+1, m+1, r, x, p);
tree[i] = merge(tree[i*2], tree[i*2+1]);
}
pair<int, int> query(int i, int l, int r, int s, int e){
if(r<s || e<l) return make_pair(0, 0);
if(s<=l && r<=e) return tree[i];
int m = (l+r)>>1;
return merge(query(i*2, l, m, s, e), query(i*2+1, m+1, r, s, e));
}
} tree;
int n, k, q;
vector<pair<int, int> > vec;
vector<int> intvOn[500002];
vector<pair<int, int> > queries[500002];
int loc[500002];
int ans[500002];
int main(){
scanf("%d %d %d", &n, &k, &q);
for(int i=1; i<=k; i++){
int l, r;
scanf("%d %d", &l, &r);
vec.push_back(make_pair(l, r));
}
for(int i=1; i<=q; i++){
int l, r;
scanf("%d %d", &l, &r);
queries[r].push_back(make_pair(l, i));
}
vec.push_back(make_pair(0, 0));
sort(vec.begin(), vec.end());
for(int i=1; i<=k; i++){
intvOn[vec[i].second].push_back(i);
}
for(int i=1; i<=n; i++){
loc[i] = loc[i-1];
while(loc[i] <= k && vec[loc[i]].first < i) loc[i]++;
}
//for(int i=1; i<=n; i++) printf("loc[%d]: %d\n", i, loc[i]);
for(int i=1; i<=n; i++){
for(int x: intvOn[i]){
tree.update(1, 1, k, x, vec[x]);
}
for(pair<int, int> p: queries[i]){
int l = p.first, idx = p.second;
pair<int, int> pr = tree.query(1, 1, k, loc[l], k);
if(pr == make_pair(l, i)) ans[idx] = 1;
}
}
for(int i=1; i<=q; i++) printf("%s\n", ans[i] ? "YES" : "NO");
}
Compilation message
curtains.cpp: In function 'int main()':
curtains.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
44 | scanf("%d %d %d", &n, &k, &q);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | scanf("%d %d", &l, &r);
| ~~~~~^~~~~~~~~~~~~~~~~
curtains.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | scanf("%d %d", &l, &r);
| ~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23788 KB |
Output is correct |
2 |
Correct |
12 ms |
23772 KB |
Output is correct |
3 |
Correct |
12 ms |
23748 KB |
Output is correct |
4 |
Correct |
11 ms |
23764 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
12 ms |
23796 KB |
Output is correct |
7 |
Correct |
13 ms |
23732 KB |
Output is correct |
8 |
Correct |
11 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23764 KB |
Output is correct |
10 |
Correct |
11 ms |
23764 KB |
Output is correct |
11 |
Correct |
11 ms |
23812 KB |
Output is correct |
12 |
Correct |
11 ms |
23776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23788 KB |
Output is correct |
2 |
Correct |
12 ms |
23772 KB |
Output is correct |
3 |
Correct |
12 ms |
23748 KB |
Output is correct |
4 |
Correct |
11 ms |
23764 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
12 ms |
23796 KB |
Output is correct |
7 |
Correct |
13 ms |
23732 KB |
Output is correct |
8 |
Correct |
11 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23764 KB |
Output is correct |
10 |
Correct |
11 ms |
23764 KB |
Output is correct |
11 |
Correct |
11 ms |
23812 KB |
Output is correct |
12 |
Correct |
11 ms |
23776 KB |
Output is correct |
13 |
Correct |
12 ms |
23904 KB |
Output is correct |
14 |
Correct |
12 ms |
23940 KB |
Output is correct |
15 |
Correct |
13 ms |
23892 KB |
Output is correct |
16 |
Correct |
13 ms |
23948 KB |
Output is correct |
17 |
Correct |
13 ms |
23892 KB |
Output is correct |
18 |
Correct |
13 ms |
23916 KB |
Output is correct |
19 |
Correct |
13 ms |
23892 KB |
Output is correct |
20 |
Correct |
16 ms |
23940 KB |
Output is correct |
21 |
Correct |
15 ms |
23892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23788 KB |
Output is correct |
2 |
Correct |
12 ms |
23772 KB |
Output is correct |
3 |
Correct |
12 ms |
23748 KB |
Output is correct |
4 |
Correct |
11 ms |
23764 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
12 ms |
23796 KB |
Output is correct |
7 |
Correct |
13 ms |
23732 KB |
Output is correct |
8 |
Correct |
11 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23764 KB |
Output is correct |
10 |
Correct |
11 ms |
23764 KB |
Output is correct |
11 |
Correct |
11 ms |
23812 KB |
Output is correct |
12 |
Correct |
11 ms |
23776 KB |
Output is correct |
13 |
Correct |
12 ms |
23904 KB |
Output is correct |
14 |
Correct |
12 ms |
23940 KB |
Output is correct |
15 |
Correct |
13 ms |
23892 KB |
Output is correct |
16 |
Correct |
13 ms |
23948 KB |
Output is correct |
17 |
Correct |
13 ms |
23892 KB |
Output is correct |
18 |
Correct |
13 ms |
23916 KB |
Output is correct |
19 |
Correct |
13 ms |
23892 KB |
Output is correct |
20 |
Correct |
16 ms |
23940 KB |
Output is correct |
21 |
Correct |
15 ms |
23892 KB |
Output is correct |
22 |
Correct |
148 ms |
35052 KB |
Output is correct |
23 |
Correct |
168 ms |
35648 KB |
Output is correct |
24 |
Correct |
212 ms |
38424 KB |
Output is correct |
25 |
Correct |
364 ms |
50136 KB |
Output is correct |
26 |
Correct |
190 ms |
35372 KB |
Output is correct |
27 |
Correct |
363 ms |
50060 KB |
Output is correct |
28 |
Correct |
385 ms |
50236 KB |
Output is correct |
29 |
Correct |
150 ms |
34456 KB |
Output is correct |
30 |
Correct |
113 ms |
35660 KB |
Output is correct |
31 |
Correct |
133 ms |
36920 KB |
Output is correct |
32 |
Correct |
291 ms |
50120 KB |
Output is correct |
33 |
Correct |
118 ms |
35740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
23764 KB |
Output is correct |
2 |
Correct |
11 ms |
23800 KB |
Output is correct |
3 |
Correct |
11 ms |
23800 KB |
Output is correct |
4 |
Correct |
13 ms |
23828 KB |
Output is correct |
5 |
Correct |
15 ms |
23928 KB |
Output is correct |
6 |
Correct |
14 ms |
23948 KB |
Output is correct |
7 |
Correct |
12 ms |
23944 KB |
Output is correct |
8 |
Correct |
114 ms |
35680 KB |
Output is correct |
9 |
Correct |
130 ms |
36944 KB |
Output is correct |
10 |
Correct |
292 ms |
50192 KB |
Output is correct |
11 |
Correct |
113 ms |
35784 KB |
Output is correct |
12 |
Correct |
85 ms |
34204 KB |
Output is correct |
13 |
Correct |
91 ms |
34180 KB |
Output is correct |
14 |
Correct |
77 ms |
33936 KB |
Output is correct |
15 |
Correct |
91 ms |
33636 KB |
Output is correct |
16 |
Correct |
80 ms |
33820 KB |
Output is correct |
17 |
Correct |
74 ms |
33480 KB |
Output is correct |
18 |
Correct |
509 ms |
67780 KB |
Output is correct |
19 |
Correct |
546 ms |
67716 KB |
Output is correct |
20 |
Correct |
402 ms |
67256 KB |
Output is correct |
21 |
Correct |
435 ms |
65600 KB |
Output is correct |
22 |
Correct |
404 ms |
64688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23788 KB |
Output is correct |
2 |
Correct |
12 ms |
23772 KB |
Output is correct |
3 |
Correct |
12 ms |
23748 KB |
Output is correct |
4 |
Correct |
11 ms |
23764 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
12 ms |
23796 KB |
Output is correct |
7 |
Correct |
13 ms |
23732 KB |
Output is correct |
8 |
Correct |
11 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23764 KB |
Output is correct |
10 |
Correct |
11 ms |
23764 KB |
Output is correct |
11 |
Correct |
11 ms |
23812 KB |
Output is correct |
12 |
Correct |
11 ms |
23776 KB |
Output is correct |
13 |
Correct |
12 ms |
23904 KB |
Output is correct |
14 |
Correct |
12 ms |
23940 KB |
Output is correct |
15 |
Correct |
13 ms |
23892 KB |
Output is correct |
16 |
Correct |
13 ms |
23948 KB |
Output is correct |
17 |
Correct |
13 ms |
23892 KB |
Output is correct |
18 |
Correct |
13 ms |
23916 KB |
Output is correct |
19 |
Correct |
13 ms |
23892 KB |
Output is correct |
20 |
Correct |
16 ms |
23940 KB |
Output is correct |
21 |
Correct |
15 ms |
23892 KB |
Output is correct |
22 |
Correct |
85 ms |
31144 KB |
Output is correct |
23 |
Correct |
88 ms |
31052 KB |
Output is correct |
24 |
Correct |
123 ms |
33036 KB |
Output is correct |
25 |
Correct |
120 ms |
32984 KB |
Output is correct |
26 |
Correct |
94 ms |
34352 KB |
Output is correct |
27 |
Correct |
85 ms |
34348 KB |
Output is correct |
28 |
Correct |
74 ms |
31248 KB |
Output is correct |
29 |
Correct |
91 ms |
33752 KB |
Output is correct |
30 |
Correct |
111 ms |
33052 KB |
Output is correct |
31 |
Correct |
117 ms |
33036 KB |
Output is correct |
32 |
Correct |
102 ms |
33444 KB |
Output is correct |
33 |
Correct |
108 ms |
33836 KB |
Output is correct |
34 |
Correct |
93 ms |
32576 KB |
Output is correct |
35 |
Correct |
98 ms |
32880 KB |
Output is correct |
36 |
Correct |
107 ms |
33440 KB |
Output is correct |
37 |
Correct |
84 ms |
34216 KB |
Output is correct |
38 |
Correct |
85 ms |
34192 KB |
Output is correct |
39 |
Correct |
77 ms |
33872 KB |
Output is correct |
40 |
Correct |
76 ms |
33356 KB |
Output is correct |
41 |
Correct |
77 ms |
33900 KB |
Output is correct |
42 |
Correct |
80 ms |
33444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23788 KB |
Output is correct |
2 |
Correct |
12 ms |
23772 KB |
Output is correct |
3 |
Correct |
12 ms |
23748 KB |
Output is correct |
4 |
Correct |
11 ms |
23764 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
12 ms |
23796 KB |
Output is correct |
7 |
Correct |
13 ms |
23732 KB |
Output is correct |
8 |
Correct |
11 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23764 KB |
Output is correct |
10 |
Correct |
11 ms |
23764 KB |
Output is correct |
11 |
Correct |
11 ms |
23812 KB |
Output is correct |
12 |
Correct |
11 ms |
23776 KB |
Output is correct |
13 |
Correct |
12 ms |
23904 KB |
Output is correct |
14 |
Correct |
12 ms |
23940 KB |
Output is correct |
15 |
Correct |
13 ms |
23892 KB |
Output is correct |
16 |
Correct |
13 ms |
23948 KB |
Output is correct |
17 |
Correct |
13 ms |
23892 KB |
Output is correct |
18 |
Correct |
13 ms |
23916 KB |
Output is correct |
19 |
Correct |
13 ms |
23892 KB |
Output is correct |
20 |
Correct |
16 ms |
23940 KB |
Output is correct |
21 |
Correct |
15 ms |
23892 KB |
Output is correct |
22 |
Correct |
148 ms |
35052 KB |
Output is correct |
23 |
Correct |
168 ms |
35648 KB |
Output is correct |
24 |
Correct |
212 ms |
38424 KB |
Output is correct |
25 |
Correct |
364 ms |
50136 KB |
Output is correct |
26 |
Correct |
190 ms |
35372 KB |
Output is correct |
27 |
Correct |
363 ms |
50060 KB |
Output is correct |
28 |
Correct |
385 ms |
50236 KB |
Output is correct |
29 |
Correct |
150 ms |
34456 KB |
Output is correct |
30 |
Correct |
113 ms |
35660 KB |
Output is correct |
31 |
Correct |
133 ms |
36920 KB |
Output is correct |
32 |
Correct |
291 ms |
50120 KB |
Output is correct |
33 |
Correct |
118 ms |
35740 KB |
Output is correct |
34 |
Correct |
15 ms |
23764 KB |
Output is correct |
35 |
Correct |
11 ms |
23800 KB |
Output is correct |
36 |
Correct |
11 ms |
23800 KB |
Output is correct |
37 |
Correct |
13 ms |
23828 KB |
Output is correct |
38 |
Correct |
15 ms |
23928 KB |
Output is correct |
39 |
Correct |
14 ms |
23948 KB |
Output is correct |
40 |
Correct |
12 ms |
23944 KB |
Output is correct |
41 |
Correct |
114 ms |
35680 KB |
Output is correct |
42 |
Correct |
130 ms |
36944 KB |
Output is correct |
43 |
Correct |
292 ms |
50192 KB |
Output is correct |
44 |
Correct |
113 ms |
35784 KB |
Output is correct |
45 |
Correct |
85 ms |
34204 KB |
Output is correct |
46 |
Correct |
91 ms |
34180 KB |
Output is correct |
47 |
Correct |
77 ms |
33936 KB |
Output is correct |
48 |
Correct |
91 ms |
33636 KB |
Output is correct |
49 |
Correct |
80 ms |
33820 KB |
Output is correct |
50 |
Correct |
74 ms |
33480 KB |
Output is correct |
51 |
Correct |
509 ms |
67780 KB |
Output is correct |
52 |
Correct |
546 ms |
67716 KB |
Output is correct |
53 |
Correct |
402 ms |
67256 KB |
Output is correct |
54 |
Correct |
435 ms |
65600 KB |
Output is correct |
55 |
Correct |
404 ms |
64688 KB |
Output is correct |
56 |
Correct |
85 ms |
31144 KB |
Output is correct |
57 |
Correct |
88 ms |
31052 KB |
Output is correct |
58 |
Correct |
123 ms |
33036 KB |
Output is correct |
59 |
Correct |
120 ms |
32984 KB |
Output is correct |
60 |
Correct |
94 ms |
34352 KB |
Output is correct |
61 |
Correct |
85 ms |
34348 KB |
Output is correct |
62 |
Correct |
74 ms |
31248 KB |
Output is correct |
63 |
Correct |
91 ms |
33752 KB |
Output is correct |
64 |
Correct |
111 ms |
33052 KB |
Output is correct |
65 |
Correct |
117 ms |
33036 KB |
Output is correct |
66 |
Correct |
102 ms |
33444 KB |
Output is correct |
67 |
Correct |
108 ms |
33836 KB |
Output is correct |
68 |
Correct |
93 ms |
32576 KB |
Output is correct |
69 |
Correct |
98 ms |
32880 KB |
Output is correct |
70 |
Correct |
107 ms |
33440 KB |
Output is correct |
71 |
Correct |
84 ms |
34216 KB |
Output is correct |
72 |
Correct |
85 ms |
34192 KB |
Output is correct |
73 |
Correct |
77 ms |
33872 KB |
Output is correct |
74 |
Correct |
76 ms |
33356 KB |
Output is correct |
75 |
Correct |
77 ms |
33900 KB |
Output is correct |
76 |
Correct |
80 ms |
33444 KB |
Output is correct |
77 |
Correct |
708 ms |
61876 KB |
Output is correct |
78 |
Correct |
723 ms |
61892 KB |
Output is correct |
79 |
Correct |
482 ms |
68460 KB |
Output is correct |
80 |
Correct |
527 ms |
68464 KB |
Output is correct |
81 |
Correct |
503 ms |
66440 KB |
Output is correct |
82 |
Correct |
495 ms |
66832 KB |
Output is correct |
83 |
Correct |
671 ms |
61816 KB |
Output is correct |
84 |
Correct |
653 ms |
61824 KB |
Output is correct |
85 |
Correct |
631 ms |
63388 KB |
Output is correct |
86 |
Correct |
532 ms |
60296 KB |
Output is correct |
87 |
Correct |
570 ms |
60760 KB |
Output is correct |
88 |
Correct |
602 ms |
66524 KB |
Output is correct |