#include <bits/stdc++.h>
using namespace std;
#define tol(bi) (1LL<<((int)(bi)))
typedef long long ll;
constexpr int MOD = 1e9+7;
constexpr int MAXS = 2000005;
constexpr int MAXN = 500002;
int segtree[MAXS]={};
struct SegTree{
SegTree(int n){/*nothin'*/}
void dallan(int node){
if (node*2+2<MAXS){
segtree[node*2+1]=max(segtree[node*2+1],segtree[node]);
segtree[node*2+2]=max(segtree[node*2+2],segtree[node]);
}
}
void update(int tarl, int tarr, int val, int l = 0, int r = MAXN, int node = 0){
dallan(node);
if (l>=tarl && r<=tarr){
segtree[node]=max(segtree[node],val);
dallan(node);
return;
}
int mid = l+(r-l)/2;
if (mid>=tarl) update(tarl, tarr, val, l, mid, node*2+1);
if (mid+1<=tarr) update(tarl, tarr, val, mid+1, r, node*2+2);
segtree[node]=min(segtree[node*2+1],segtree[node*2+2]);
}
int query(int tarl, int tarr, int l = 0, int r = MAXN, int node = 0){
dallan(node);
if (l>=tarl && r<=tarr) return segtree[node];
int mid = l+(r-l)/2;
int lnode = MOD, rnode = MOD;
if (mid>=tarl) lnode = query(tarl, tarr, l, mid, node*2+1);
if (mid+1<=tarr) rnode = query(tarl, tarr, mid+1, r, node*2+2);
return min(lnode, rnode);
}
};
int main(){
memset(segtree,-1,sizeof(segtree));
int n,m,q;
cin>>n>>m>>q;
SegTree segtree(n);
vector<pair<int,int>> arr(m);
for (int i = 0; i < m; ++i)
{
cin>>arr[i].first>>arr[i].second;
}
sort(arr.begin(), arr.end(), [&](pair<int,int> a, pair<int,int> b){
return a.second<b.second;
});
int ind = 0;
vector<array<int,3>> qarr(q);
vector<bool> ansarr(q,false);
for (int i = 0; i < q; ++i)
{
cin>>qarr[i][0]>>qarr[i][1];
qarr[i][2]=i;
}
sort(qarr.begin(), qarr.end(), [&](array<int,3> a, array<int,3> b){
return a[1]<b[1];
});
for (int i = 0; i < q; ++i)
{
while (ind<m && arr[ind].second<=qarr[i][1]){
segtree.update(arr[ind].first-1,arr[ind].second-1,arr[ind].first-1);
ind++;
}
if (segtree.query(qarr[i][0]-1,qarr[i][1]-1)>=qarr[i][0]-1) ansarr[qarr[i][2]]=true;
}
for (int i = 0; i < q; ++i)
{
if (ansarr[i]) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8088 KB |
Output is correct |
3 |
Correct |
2 ms |
8024 KB |
Output is correct |
4 |
Correct |
2 ms |
8028 KB |
Output is correct |
5 |
Correct |
3 ms |
8028 KB |
Output is correct |
6 |
Correct |
2 ms |
8048 KB |
Output is correct |
7 |
Correct |
2 ms |
8028 KB |
Output is correct |
8 |
Correct |
2 ms |
8028 KB |
Output is correct |
9 |
Correct |
2 ms |
8028 KB |
Output is correct |
10 |
Correct |
2 ms |
8024 KB |
Output is correct |
11 |
Correct |
2 ms |
8024 KB |
Output is correct |
12 |
Correct |
2 ms |
8028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8088 KB |
Output is correct |
3 |
Correct |
2 ms |
8024 KB |
Output is correct |
4 |
Correct |
2 ms |
8028 KB |
Output is correct |
5 |
Correct |
3 ms |
8028 KB |
Output is correct |
6 |
Correct |
2 ms |
8048 KB |
Output is correct |
7 |
Correct |
2 ms |
8028 KB |
Output is correct |
8 |
Correct |
2 ms |
8028 KB |
Output is correct |
9 |
Correct |
2 ms |
8028 KB |
Output is correct |
10 |
Correct |
2 ms |
8024 KB |
Output is correct |
11 |
Correct |
2 ms |
8024 KB |
Output is correct |
12 |
Correct |
2 ms |
8028 KB |
Output is correct |
13 |
Correct |
6 ms |
8284 KB |
Output is correct |
14 |
Correct |
7 ms |
8296 KB |
Output is correct |
15 |
Correct |
7 ms |
8284 KB |
Output is correct |
16 |
Correct |
9 ms |
8280 KB |
Output is correct |
17 |
Correct |
8 ms |
8276 KB |
Output is correct |
18 |
Correct |
8 ms |
8284 KB |
Output is correct |
19 |
Correct |
6 ms |
8300 KB |
Output is correct |
20 |
Correct |
6 ms |
8280 KB |
Output is correct |
21 |
Correct |
6 ms |
8284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8088 KB |
Output is correct |
3 |
Correct |
2 ms |
8024 KB |
Output is correct |
4 |
Correct |
2 ms |
8028 KB |
Output is correct |
5 |
Correct |
3 ms |
8028 KB |
Output is correct |
6 |
Correct |
2 ms |
8048 KB |
Output is correct |
7 |
Correct |
2 ms |
8028 KB |
Output is correct |
8 |
Correct |
2 ms |
8028 KB |
Output is correct |
9 |
Correct |
2 ms |
8028 KB |
Output is correct |
10 |
Correct |
2 ms |
8024 KB |
Output is correct |
11 |
Correct |
2 ms |
8024 KB |
Output is correct |
12 |
Correct |
2 ms |
8028 KB |
Output is correct |
13 |
Correct |
6 ms |
8284 KB |
Output is correct |
14 |
Correct |
7 ms |
8296 KB |
Output is correct |
15 |
Correct |
7 ms |
8284 KB |
Output is correct |
16 |
Correct |
9 ms |
8280 KB |
Output is correct |
17 |
Correct |
8 ms |
8276 KB |
Output is correct |
18 |
Correct |
8 ms |
8284 KB |
Output is correct |
19 |
Correct |
6 ms |
8300 KB |
Output is correct |
20 |
Correct |
6 ms |
8280 KB |
Output is correct |
21 |
Correct |
6 ms |
8284 KB |
Output is correct |
22 |
Correct |
830 ms |
15720 KB |
Output is correct |
23 |
Correct |
879 ms |
16208 KB |
Output is correct |
24 |
Correct |
890 ms |
17012 KB |
Output is correct |
25 |
Correct |
1156 ms |
20052 KB |
Output is correct |
26 |
Correct |
829 ms |
16024 KB |
Output is correct |
27 |
Correct |
1142 ms |
19884 KB |
Output is correct |
28 |
Correct |
1138 ms |
20164 KB |
Output is correct |
29 |
Correct |
805 ms |
15840 KB |
Output is correct |
30 |
Correct |
769 ms |
15956 KB |
Output is correct |
31 |
Correct |
795 ms |
16588 KB |
Output is correct |
32 |
Correct |
1116 ms |
19884 KB |
Output is correct |
33 |
Correct |
795 ms |
16104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8028 KB |
Output is correct |
3 |
Correct |
2 ms |
8028 KB |
Output is correct |
4 |
Correct |
3 ms |
8028 KB |
Output is correct |
5 |
Correct |
8 ms |
8536 KB |
Output is correct |
6 |
Correct |
6 ms |
8284 KB |
Output is correct |
7 |
Correct |
6 ms |
8280 KB |
Output is correct |
8 |
Correct |
754 ms |
16108 KB |
Output is correct |
9 |
Correct |
777 ms |
16608 KB |
Output is correct |
10 |
Correct |
1095 ms |
19904 KB |
Output is correct |
11 |
Correct |
755 ms |
16048 KB |
Output is correct |
12 |
Correct |
240 ms |
10328 KB |
Output is correct |
13 |
Correct |
249 ms |
10320 KB |
Output is correct |
14 |
Correct |
226 ms |
10352 KB |
Output is correct |
15 |
Correct |
220 ms |
10324 KB |
Output is correct |
16 |
Correct |
223 ms |
10484 KB |
Output is correct |
17 |
Correct |
221 ms |
10316 KB |
Output is correct |
18 |
Correct |
1256 ms |
19668 KB |
Output is correct |
19 |
Correct |
1265 ms |
19704 KB |
Output is correct |
20 |
Correct |
1132 ms |
19388 KB |
Output is correct |
21 |
Correct |
1137 ms |
19568 KB |
Output is correct |
22 |
Correct |
1137 ms |
19680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8088 KB |
Output is correct |
3 |
Correct |
2 ms |
8024 KB |
Output is correct |
4 |
Correct |
2 ms |
8028 KB |
Output is correct |
5 |
Correct |
3 ms |
8028 KB |
Output is correct |
6 |
Correct |
2 ms |
8048 KB |
Output is correct |
7 |
Correct |
2 ms |
8028 KB |
Output is correct |
8 |
Correct |
2 ms |
8028 KB |
Output is correct |
9 |
Correct |
2 ms |
8028 KB |
Output is correct |
10 |
Correct |
2 ms |
8024 KB |
Output is correct |
11 |
Correct |
2 ms |
8024 KB |
Output is correct |
12 |
Correct |
2 ms |
8028 KB |
Output is correct |
13 |
Correct |
6 ms |
8284 KB |
Output is correct |
14 |
Correct |
7 ms |
8296 KB |
Output is correct |
15 |
Correct |
7 ms |
8284 KB |
Output is correct |
16 |
Correct |
9 ms |
8280 KB |
Output is correct |
17 |
Correct |
8 ms |
8276 KB |
Output is correct |
18 |
Correct |
8 ms |
8284 KB |
Output is correct |
19 |
Correct |
6 ms |
8300 KB |
Output is correct |
20 |
Correct |
6 ms |
8280 KB |
Output is correct |
21 |
Correct |
6 ms |
8284 KB |
Output is correct |
22 |
Correct |
244 ms |
10576 KB |
Output is correct |
23 |
Correct |
242 ms |
10584 KB |
Output is correct |
24 |
Correct |
282 ms |
10320 KB |
Output is correct |
25 |
Correct |
272 ms |
10584 KB |
Output is correct |
26 |
Correct |
247 ms |
10576 KB |
Output is correct |
27 |
Correct |
244 ms |
10580 KB |
Output is correct |
28 |
Correct |
224 ms |
9936 KB |
Output is correct |
29 |
Correct |
233 ms |
10324 KB |
Output is correct |
30 |
Correct |
270 ms |
10328 KB |
Output is correct |
31 |
Correct |
264 ms |
10308 KB |
Output is correct |
32 |
Correct |
249 ms |
10324 KB |
Output is correct |
33 |
Correct |
244 ms |
10324 KB |
Output is correct |
34 |
Correct |
258 ms |
10316 KB |
Output is correct |
35 |
Correct |
276 ms |
10584 KB |
Output is correct |
36 |
Correct |
253 ms |
10316 KB |
Output is correct |
37 |
Correct |
242 ms |
10572 KB |
Output is correct |
38 |
Correct |
244 ms |
10332 KB |
Output is correct |
39 |
Correct |
222 ms |
10308 KB |
Output is correct |
40 |
Correct |
252 ms |
10828 KB |
Output is correct |
41 |
Correct |
228 ms |
10456 KB |
Output is correct |
42 |
Correct |
222 ms |
10316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8088 KB |
Output is correct |
3 |
Correct |
2 ms |
8024 KB |
Output is correct |
4 |
Correct |
2 ms |
8028 KB |
Output is correct |
5 |
Correct |
3 ms |
8028 KB |
Output is correct |
6 |
Correct |
2 ms |
8048 KB |
Output is correct |
7 |
Correct |
2 ms |
8028 KB |
Output is correct |
8 |
Correct |
2 ms |
8028 KB |
Output is correct |
9 |
Correct |
2 ms |
8028 KB |
Output is correct |
10 |
Correct |
2 ms |
8024 KB |
Output is correct |
11 |
Correct |
2 ms |
8024 KB |
Output is correct |
12 |
Correct |
2 ms |
8028 KB |
Output is correct |
13 |
Correct |
6 ms |
8284 KB |
Output is correct |
14 |
Correct |
7 ms |
8296 KB |
Output is correct |
15 |
Correct |
7 ms |
8284 KB |
Output is correct |
16 |
Correct |
9 ms |
8280 KB |
Output is correct |
17 |
Correct |
8 ms |
8276 KB |
Output is correct |
18 |
Correct |
8 ms |
8284 KB |
Output is correct |
19 |
Correct |
6 ms |
8300 KB |
Output is correct |
20 |
Correct |
6 ms |
8280 KB |
Output is correct |
21 |
Correct |
6 ms |
8284 KB |
Output is correct |
22 |
Correct |
830 ms |
15720 KB |
Output is correct |
23 |
Correct |
879 ms |
16208 KB |
Output is correct |
24 |
Correct |
890 ms |
17012 KB |
Output is correct |
25 |
Correct |
1156 ms |
20052 KB |
Output is correct |
26 |
Correct |
829 ms |
16024 KB |
Output is correct |
27 |
Correct |
1142 ms |
19884 KB |
Output is correct |
28 |
Correct |
1138 ms |
20164 KB |
Output is correct |
29 |
Correct |
805 ms |
15840 KB |
Output is correct |
30 |
Correct |
769 ms |
15956 KB |
Output is correct |
31 |
Correct |
795 ms |
16588 KB |
Output is correct |
32 |
Correct |
1116 ms |
19884 KB |
Output is correct |
33 |
Correct |
795 ms |
16104 KB |
Output is correct |
34 |
Correct |
2 ms |
8028 KB |
Output is correct |
35 |
Correct |
2 ms |
8028 KB |
Output is correct |
36 |
Correct |
2 ms |
8028 KB |
Output is correct |
37 |
Correct |
3 ms |
8028 KB |
Output is correct |
38 |
Correct |
8 ms |
8536 KB |
Output is correct |
39 |
Correct |
6 ms |
8284 KB |
Output is correct |
40 |
Correct |
6 ms |
8280 KB |
Output is correct |
41 |
Correct |
754 ms |
16108 KB |
Output is correct |
42 |
Correct |
777 ms |
16608 KB |
Output is correct |
43 |
Correct |
1095 ms |
19904 KB |
Output is correct |
44 |
Correct |
755 ms |
16048 KB |
Output is correct |
45 |
Correct |
240 ms |
10328 KB |
Output is correct |
46 |
Correct |
249 ms |
10320 KB |
Output is correct |
47 |
Correct |
226 ms |
10352 KB |
Output is correct |
48 |
Correct |
220 ms |
10324 KB |
Output is correct |
49 |
Correct |
223 ms |
10484 KB |
Output is correct |
50 |
Correct |
221 ms |
10316 KB |
Output is correct |
51 |
Correct |
1256 ms |
19668 KB |
Output is correct |
52 |
Correct |
1265 ms |
19704 KB |
Output is correct |
53 |
Correct |
1132 ms |
19388 KB |
Output is correct |
54 |
Correct |
1137 ms |
19568 KB |
Output is correct |
55 |
Correct |
1137 ms |
19680 KB |
Output is correct |
56 |
Correct |
244 ms |
10576 KB |
Output is correct |
57 |
Correct |
242 ms |
10584 KB |
Output is correct |
58 |
Correct |
282 ms |
10320 KB |
Output is correct |
59 |
Correct |
272 ms |
10584 KB |
Output is correct |
60 |
Correct |
247 ms |
10576 KB |
Output is correct |
61 |
Correct |
244 ms |
10580 KB |
Output is correct |
62 |
Correct |
224 ms |
9936 KB |
Output is correct |
63 |
Correct |
233 ms |
10324 KB |
Output is correct |
64 |
Correct |
270 ms |
10328 KB |
Output is correct |
65 |
Correct |
264 ms |
10308 KB |
Output is correct |
66 |
Correct |
249 ms |
10324 KB |
Output is correct |
67 |
Correct |
244 ms |
10324 KB |
Output is correct |
68 |
Correct |
258 ms |
10316 KB |
Output is correct |
69 |
Correct |
276 ms |
10584 KB |
Output is correct |
70 |
Correct |
253 ms |
10316 KB |
Output is correct |
71 |
Correct |
242 ms |
10572 KB |
Output is correct |
72 |
Correct |
244 ms |
10332 KB |
Output is correct |
73 |
Correct |
222 ms |
10308 KB |
Output is correct |
74 |
Correct |
252 ms |
10828 KB |
Output is correct |
75 |
Correct |
228 ms |
10456 KB |
Output is correct |
76 |
Correct |
222 ms |
10316 KB |
Output is correct |
77 |
Correct |
1438 ms |
19840 KB |
Output is correct |
78 |
Correct |
1447 ms |
19584 KB |
Output is correct |
79 |
Correct |
1312 ms |
19984 KB |
Output is correct |
80 |
Correct |
1332 ms |
19908 KB |
Output is correct |
81 |
Correct |
1252 ms |
19792 KB |
Output is correct |
82 |
Correct |
1270 ms |
19296 KB |
Output is correct |
83 |
Correct |
1386 ms |
19844 KB |
Output is correct |
84 |
Correct |
1389 ms |
19936 KB |
Output is correct |
85 |
Correct |
1344 ms |
19840 KB |
Output is correct |
86 |
Correct |
1354 ms |
19688 KB |
Output is correct |
87 |
Correct |
1359 ms |
19868 KB |
Output is correct |
88 |
Correct |
1279 ms |
20100 KB |
Output is correct |