#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 7;
const int inf = 1e9 + 7;
struct SEGT{
int tree[N];
SEGT(){
for(int i = 0;i<N;i++){
tree[i] = inf;
}
}
void update(int ind , int l , int r , int ql , int qr){
if(l >= ql and r <= qr){
tree[ind] = min(tree[ind] , qr);
return;
}
else if(l > qr or r < ql){
return;
}
else{
int mid = (l+r)/2;
update(ind*2,l,mid,ql,qr);
update(ind*2+1,mid+1,r,ql,qr);
tree[ind] = min(tree[ind] , max(tree[ind*2] , tree[ind*2+1]));
}
}
bool query(int ind , int l , int r , int ql , int qr){
if(l >= ql and r <= qr){
return tree[ind] <= qr;
}
else if(l > qr or r < ql){
return 1;
}
else{
int mid = (l+r)/2;
return query(ind*2,l,mid,ql,qr) and query(ind*2+1,mid+1,r,ql,qr);
}
}
} segt;
void solve(){
int n,m,q;
cin >> n >> m >> q;
vector < int > ran[n+1];
vector < pair < int , int > > query[n+1];
for(int i = 0;i<m;i++){
int x,y;
cin >> x >> y;
ran[x].push_back(y);
}
for(int i = 0;i<q;i++){
int x,y;
cin >> x >> y;
query[x].push_back({y,i});
}
int ans[q];
for(int i = n;i>0;i--){
for(auto itr : ran[i]){
segt.update(1,1,n,i,itr);
}
for(auto itr : query[i]){
ans[itr.second] = segt.query(1,1,n,i,itr.first);
}
}
for(int i = 0;i<q;i++){
cout << (ans[i] ? "YES\n" : "NO\n");
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8280 KB |
Output is correct |
4 |
Correct |
2 ms |
8284 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
2 ms |
8284 KB |
Output is correct |
11 |
Correct |
2 ms |
8284 KB |
Output is correct |
12 |
Correct |
2 ms |
8284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8280 KB |
Output is correct |
4 |
Correct |
2 ms |
8284 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
2 ms |
8284 KB |
Output is correct |
11 |
Correct |
2 ms |
8284 KB |
Output is correct |
12 |
Correct |
2 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8284 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8280 KB |
Output is correct |
17 |
Correct |
3 ms |
8452 KB |
Output is correct |
18 |
Correct |
3 ms |
8284 KB |
Output is correct |
19 |
Correct |
3 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
3 ms |
8304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8280 KB |
Output is correct |
4 |
Correct |
2 ms |
8284 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
2 ms |
8284 KB |
Output is correct |
11 |
Correct |
2 ms |
8284 KB |
Output is correct |
12 |
Correct |
2 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8284 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8280 KB |
Output is correct |
17 |
Correct |
3 ms |
8452 KB |
Output is correct |
18 |
Correct |
3 ms |
8284 KB |
Output is correct |
19 |
Correct |
3 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
3 ms |
8304 KB |
Output is correct |
22 |
Correct |
94 ms |
18000 KB |
Output is correct |
23 |
Correct |
120 ms |
18256 KB |
Output is correct |
24 |
Correct |
149 ms |
18916 KB |
Output is correct |
25 |
Correct |
274 ms |
21168 KB |
Output is correct |
26 |
Correct |
133 ms |
18172 KB |
Output is correct |
27 |
Correct |
250 ms |
21420 KB |
Output is correct |
28 |
Correct |
237 ms |
21160 KB |
Output is correct |
29 |
Correct |
102 ms |
18308 KB |
Output is correct |
30 |
Correct |
104 ms |
16216 KB |
Output is correct |
31 |
Correct |
112 ms |
16508 KB |
Output is correct |
32 |
Correct |
213 ms |
19568 KB |
Output is correct |
33 |
Correct |
103 ms |
16308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8024 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8280 KB |
Output is correct |
4 |
Correct |
2 ms |
8280 KB |
Output is correct |
5 |
Correct |
3 ms |
8284 KB |
Output is correct |
6 |
Correct |
4 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
111 ms |
16196 KB |
Output is correct |
9 |
Correct |
133 ms |
16576 KB |
Output is correct |
10 |
Correct |
255 ms |
19360 KB |
Output is correct |
11 |
Correct |
101 ms |
16312 KB |
Output is correct |
12 |
Correct |
68 ms |
16356 KB |
Output is correct |
13 |
Correct |
68 ms |
16320 KB |
Output is correct |
14 |
Correct |
63 ms |
16336 KB |
Output is correct |
15 |
Correct |
49 ms |
16328 KB |
Output is correct |
16 |
Correct |
61 ms |
16336 KB |
Output is correct |
17 |
Correct |
48 ms |
16324 KB |
Output is correct |
18 |
Correct |
449 ms |
48320 KB |
Output is correct |
19 |
Correct |
426 ms |
48340 KB |
Output is correct |
20 |
Correct |
387 ms |
49436 KB |
Output is correct |
21 |
Correct |
354 ms |
48876 KB |
Output is correct |
22 |
Correct |
335 ms |
48956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8280 KB |
Output is correct |
4 |
Correct |
2 ms |
8284 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
2 ms |
8284 KB |
Output is correct |
11 |
Correct |
2 ms |
8284 KB |
Output is correct |
12 |
Correct |
2 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8284 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8280 KB |
Output is correct |
17 |
Correct |
3 ms |
8452 KB |
Output is correct |
18 |
Correct |
3 ms |
8284 KB |
Output is correct |
19 |
Correct |
3 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
3 ms |
8304 KB |
Output is correct |
22 |
Correct |
68 ms |
11600 KB |
Output is correct |
23 |
Correct |
64 ms |
11552 KB |
Output is correct |
24 |
Correct |
108 ms |
17236 KB |
Output is correct |
25 |
Correct |
81 ms |
17236 KB |
Output is correct |
26 |
Correct |
104 ms |
18756 KB |
Output is correct |
27 |
Correct |
75 ms |
18768 KB |
Output is correct |
28 |
Correct |
55 ms |
17236 KB |
Output is correct |
29 |
Correct |
69 ms |
18540 KB |
Output is correct |
30 |
Correct |
79 ms |
17288 KB |
Output is correct |
31 |
Correct |
82 ms |
17364 KB |
Output is correct |
32 |
Correct |
83 ms |
17748 KB |
Output is correct |
33 |
Correct |
80 ms |
18004 KB |
Output is correct |
34 |
Correct |
84 ms |
17120 KB |
Output is correct |
35 |
Correct |
74 ms |
16976 KB |
Output is correct |
36 |
Correct |
83 ms |
17232 KB |
Output is correct |
37 |
Correct |
70 ms |
16320 KB |
Output is correct |
38 |
Correct |
67 ms |
16332 KB |
Output is correct |
39 |
Correct |
59 ms |
16448 KB |
Output is correct |
40 |
Correct |
47 ms |
16332 KB |
Output is correct |
41 |
Correct |
48 ms |
16508 KB |
Output is correct |
42 |
Correct |
49 ms |
16328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8280 KB |
Output is correct |
4 |
Correct |
2 ms |
8284 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
2 ms |
8284 KB |
Output is correct |
11 |
Correct |
2 ms |
8284 KB |
Output is correct |
12 |
Correct |
2 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8284 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8280 KB |
Output is correct |
17 |
Correct |
3 ms |
8452 KB |
Output is correct |
18 |
Correct |
3 ms |
8284 KB |
Output is correct |
19 |
Correct |
3 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
3 ms |
8304 KB |
Output is correct |
22 |
Correct |
94 ms |
18000 KB |
Output is correct |
23 |
Correct |
120 ms |
18256 KB |
Output is correct |
24 |
Correct |
149 ms |
18916 KB |
Output is correct |
25 |
Correct |
274 ms |
21168 KB |
Output is correct |
26 |
Correct |
133 ms |
18172 KB |
Output is correct |
27 |
Correct |
250 ms |
21420 KB |
Output is correct |
28 |
Correct |
237 ms |
21160 KB |
Output is correct |
29 |
Correct |
102 ms |
18308 KB |
Output is correct |
30 |
Correct |
104 ms |
16216 KB |
Output is correct |
31 |
Correct |
112 ms |
16508 KB |
Output is correct |
32 |
Correct |
213 ms |
19568 KB |
Output is correct |
33 |
Correct |
103 ms |
16308 KB |
Output is correct |
34 |
Correct |
3 ms |
8024 KB |
Output is correct |
35 |
Correct |
3 ms |
8284 KB |
Output is correct |
36 |
Correct |
2 ms |
8280 KB |
Output is correct |
37 |
Correct |
2 ms |
8280 KB |
Output is correct |
38 |
Correct |
3 ms |
8284 KB |
Output is correct |
39 |
Correct |
4 ms |
8284 KB |
Output is correct |
40 |
Correct |
4 ms |
8284 KB |
Output is correct |
41 |
Correct |
111 ms |
16196 KB |
Output is correct |
42 |
Correct |
133 ms |
16576 KB |
Output is correct |
43 |
Correct |
255 ms |
19360 KB |
Output is correct |
44 |
Correct |
101 ms |
16312 KB |
Output is correct |
45 |
Correct |
68 ms |
16356 KB |
Output is correct |
46 |
Correct |
68 ms |
16320 KB |
Output is correct |
47 |
Correct |
63 ms |
16336 KB |
Output is correct |
48 |
Correct |
49 ms |
16328 KB |
Output is correct |
49 |
Correct |
61 ms |
16336 KB |
Output is correct |
50 |
Correct |
48 ms |
16324 KB |
Output is correct |
51 |
Correct |
449 ms |
48320 KB |
Output is correct |
52 |
Correct |
426 ms |
48340 KB |
Output is correct |
53 |
Correct |
387 ms |
49436 KB |
Output is correct |
54 |
Correct |
354 ms |
48876 KB |
Output is correct |
55 |
Correct |
335 ms |
48956 KB |
Output is correct |
56 |
Correct |
68 ms |
11600 KB |
Output is correct |
57 |
Correct |
64 ms |
11552 KB |
Output is correct |
58 |
Correct |
108 ms |
17236 KB |
Output is correct |
59 |
Correct |
81 ms |
17236 KB |
Output is correct |
60 |
Correct |
104 ms |
18756 KB |
Output is correct |
61 |
Correct |
75 ms |
18768 KB |
Output is correct |
62 |
Correct |
55 ms |
17236 KB |
Output is correct |
63 |
Correct |
69 ms |
18540 KB |
Output is correct |
64 |
Correct |
79 ms |
17288 KB |
Output is correct |
65 |
Correct |
82 ms |
17364 KB |
Output is correct |
66 |
Correct |
83 ms |
17748 KB |
Output is correct |
67 |
Correct |
80 ms |
18004 KB |
Output is correct |
68 |
Correct |
84 ms |
17120 KB |
Output is correct |
69 |
Correct |
74 ms |
16976 KB |
Output is correct |
70 |
Correct |
83 ms |
17232 KB |
Output is correct |
71 |
Correct |
70 ms |
16320 KB |
Output is correct |
72 |
Correct |
67 ms |
16332 KB |
Output is correct |
73 |
Correct |
59 ms |
16448 KB |
Output is correct |
74 |
Correct |
47 ms |
16332 KB |
Output is correct |
75 |
Correct |
48 ms |
16508 KB |
Output is correct |
76 |
Correct |
49 ms |
16328 KB |
Output is correct |
77 |
Correct |
624 ms |
61132 KB |
Output is correct |
78 |
Correct |
579 ms |
61012 KB |
Output is correct |
79 |
Correct |
645 ms |
68648 KB |
Output is correct |
80 |
Correct |
621 ms |
68636 KB |
Output is correct |
81 |
Correct |
574 ms |
66816 KB |
Output is correct |
82 |
Correct |
513 ms |
67840 KB |
Output is correct |
83 |
Correct |
635 ms |
61160 KB |
Output is correct |
84 |
Correct |
665 ms |
61048 KB |
Output is correct |
85 |
Correct |
607 ms |
62032 KB |
Output is correct |
86 |
Correct |
486 ms |
57684 KB |
Output is correct |
87 |
Correct |
463 ms |
57552 KB |
Output is correct |
88 |
Correct |
523 ms |
65360 KB |
Output is correct |