#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ins insert
#define pb push_back
#define endl '\n'
#define putr(x) cout<<x<<endl;return;
#define all(x) x.begin(),x.end()
#define _ << " " <<
mt19937 rng(time(0));
const int mod = 998244353,
sze = 5e5 +23,
inf = INT_MAX,
Lg = 31;
int T[sze*4];
int L[sze*4];
void upd(int l,int r,int v,int node=1,int lx=0,int rx=sze){
if(lx>r || rx<l){
return;
}
// cout<<node<<endl;
if(lx>=l && rx<=r){
// cout<<lx<<" "<<rx<<" "<<v<<endl;
T[node]=min(T[node],v);
L[node]=min(L[node],v);
return;
}
int mid = (lx+rx)/2;
upd(l,r,v,node*2,lx,mid);
upd(l,r,v,node*2 +1,mid+1,rx);
T[node]=min(max(T[node*2],T[node*2 +1]),L[node]);
}
int qry(int l,int r,int node=1,int lx=0,int rx=sze){
if(lx>r || rx<l){
return inf*2;
}
if(l<=lx && rx<=r){
return T[node] ;
}
int mid = (lx+rx)/2;
int left = qry(l,r,node*2,lx,mid);
int right = qry(l,r,node*2 +1,mid+1,rx);
if(left>inf){
return min(L[node],right);
}
if(right>inf){
return min(L[node],left);
}
return min(max(left,right),L[node]);
}
void _0x0(){
for(int i=0;i<sze*4;i++){
T[i]=inf;
L[i]=inf;
}
int n,m,q;
cin>>n>>m>>q;
vector<pair<int,int>> event[n+10];
vector<int> ans(q);
for(int i=0;i<m;i++){
int l,r;cin>>l>>r;
event[l].pb({-1,r});
}
for(int i=0;i<q;i++){
int l,r;cin>>l>>r;
event[l].pb({i,r});
}
for(int i = n;i>=1;i--){
sort(all(event[i]));
for(auto [k,v]:event[i]){
if(k==-1){
upd(i,v,v);
}
else{
int x = qry(i,v);
// cout<<i _ ":" _ v _ ".." _ x _ "::"<<endl;
ans[k]=(x<=v);
}
}
}
for(auto v:ans) cout<<(v?"YES":"NO")<<endl;
// upd(2,5,3);
// cout<<qry(2,5)<<endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int tt = 1;
// cin>>tt;
while(tt--){
_0x0();
}
return 0;
}
Compilation message
curtains.cpp: In function 'void _0x0()':
curtains.cpp:76:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
76 | for(auto [k,v]:event[i]){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
31576 KB |
Output is correct |
2 |
Correct |
13 ms |
31576 KB |
Output is correct |
3 |
Correct |
13 ms |
31576 KB |
Output is correct |
4 |
Correct |
13 ms |
31580 KB |
Output is correct |
5 |
Correct |
12 ms |
31580 KB |
Output is correct |
6 |
Correct |
14 ms |
31580 KB |
Output is correct |
7 |
Correct |
13 ms |
31576 KB |
Output is correct |
8 |
Correct |
12 ms |
31580 KB |
Output is correct |
9 |
Correct |
13 ms |
31580 KB |
Output is correct |
10 |
Correct |
13 ms |
31580 KB |
Output is correct |
11 |
Correct |
11 ms |
31792 KB |
Output is correct |
12 |
Correct |
13 ms |
31580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
31576 KB |
Output is correct |
2 |
Correct |
13 ms |
31576 KB |
Output is correct |
3 |
Correct |
13 ms |
31576 KB |
Output is correct |
4 |
Correct |
13 ms |
31580 KB |
Output is correct |
5 |
Correct |
12 ms |
31580 KB |
Output is correct |
6 |
Correct |
14 ms |
31580 KB |
Output is correct |
7 |
Correct |
13 ms |
31576 KB |
Output is correct |
8 |
Correct |
12 ms |
31580 KB |
Output is correct |
9 |
Correct |
13 ms |
31580 KB |
Output is correct |
10 |
Correct |
13 ms |
31580 KB |
Output is correct |
11 |
Correct |
11 ms |
31792 KB |
Output is correct |
12 |
Correct |
13 ms |
31580 KB |
Output is correct |
13 |
Correct |
15 ms |
31836 KB |
Output is correct |
14 |
Correct |
14 ms |
31836 KB |
Output is correct |
15 |
Correct |
14 ms |
31832 KB |
Output is correct |
16 |
Correct |
15 ms |
31836 KB |
Output is correct |
17 |
Correct |
14 ms |
31844 KB |
Output is correct |
18 |
Correct |
14 ms |
31884 KB |
Output is correct |
19 |
Correct |
15 ms |
31832 KB |
Output is correct |
20 |
Correct |
14 ms |
31836 KB |
Output is correct |
21 |
Correct |
13 ms |
31836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
31576 KB |
Output is correct |
2 |
Correct |
13 ms |
31576 KB |
Output is correct |
3 |
Correct |
13 ms |
31576 KB |
Output is correct |
4 |
Correct |
13 ms |
31580 KB |
Output is correct |
5 |
Correct |
12 ms |
31580 KB |
Output is correct |
6 |
Correct |
14 ms |
31580 KB |
Output is correct |
7 |
Correct |
13 ms |
31576 KB |
Output is correct |
8 |
Correct |
12 ms |
31580 KB |
Output is correct |
9 |
Correct |
13 ms |
31580 KB |
Output is correct |
10 |
Correct |
13 ms |
31580 KB |
Output is correct |
11 |
Correct |
11 ms |
31792 KB |
Output is correct |
12 |
Correct |
13 ms |
31580 KB |
Output is correct |
13 |
Correct |
15 ms |
31836 KB |
Output is correct |
14 |
Correct |
14 ms |
31836 KB |
Output is correct |
15 |
Correct |
14 ms |
31832 KB |
Output is correct |
16 |
Correct |
15 ms |
31836 KB |
Output is correct |
17 |
Correct |
14 ms |
31844 KB |
Output is correct |
18 |
Correct |
14 ms |
31884 KB |
Output is correct |
19 |
Correct |
15 ms |
31832 KB |
Output is correct |
20 |
Correct |
14 ms |
31836 KB |
Output is correct |
21 |
Correct |
13 ms |
31836 KB |
Output is correct |
22 |
Correct |
229 ms |
53564 KB |
Output is correct |
23 |
Correct |
208 ms |
54096 KB |
Output is correct |
24 |
Correct |
240 ms |
57684 KB |
Output is correct |
25 |
Correct |
402 ms |
68580 KB |
Output is correct |
26 |
Correct |
220 ms |
53840 KB |
Output is correct |
27 |
Correct |
395 ms |
68688 KB |
Output is correct |
28 |
Correct |
386 ms |
68948 KB |
Output is correct |
29 |
Correct |
202 ms |
53980 KB |
Output is correct |
30 |
Correct |
199 ms |
48816 KB |
Output is correct |
31 |
Correct |
208 ms |
50604 KB |
Output is correct |
32 |
Correct |
352 ms |
64976 KB |
Output is correct |
33 |
Correct |
194 ms |
49152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
31576 KB |
Output is correct |
2 |
Correct |
11 ms |
31580 KB |
Output is correct |
3 |
Correct |
11 ms |
31580 KB |
Output is correct |
4 |
Correct |
11 ms |
31760 KB |
Output is correct |
5 |
Correct |
13 ms |
31800 KB |
Output is correct |
6 |
Correct |
12 ms |
31836 KB |
Output is correct |
7 |
Correct |
12 ms |
31936 KB |
Output is correct |
8 |
Correct |
198 ms |
48792 KB |
Output is correct |
9 |
Correct |
218 ms |
50608 KB |
Output is correct |
10 |
Correct |
388 ms |
64952 KB |
Output is correct |
11 |
Correct |
209 ms |
49008 KB |
Output is correct |
12 |
Correct |
114 ms |
41368 KB |
Output is correct |
13 |
Correct |
122 ms |
41416 KB |
Output is correct |
14 |
Correct |
98 ms |
41420 KB |
Output is correct |
15 |
Correct |
101 ms |
41412 KB |
Output is correct |
16 |
Correct |
104 ms |
41424 KB |
Output is correct |
17 |
Correct |
112 ms |
41424 KB |
Output is correct |
18 |
Correct |
669 ms |
81068 KB |
Output is correct |
19 |
Correct |
661 ms |
80952 KB |
Output is correct |
20 |
Correct |
527 ms |
81020 KB |
Output is correct |
21 |
Correct |
537 ms |
81068 KB |
Output is correct |
22 |
Correct |
486 ms |
81072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
31576 KB |
Output is correct |
2 |
Correct |
13 ms |
31576 KB |
Output is correct |
3 |
Correct |
13 ms |
31576 KB |
Output is correct |
4 |
Correct |
13 ms |
31580 KB |
Output is correct |
5 |
Correct |
12 ms |
31580 KB |
Output is correct |
6 |
Correct |
14 ms |
31580 KB |
Output is correct |
7 |
Correct |
13 ms |
31576 KB |
Output is correct |
8 |
Correct |
12 ms |
31580 KB |
Output is correct |
9 |
Correct |
13 ms |
31580 KB |
Output is correct |
10 |
Correct |
13 ms |
31580 KB |
Output is correct |
11 |
Correct |
11 ms |
31792 KB |
Output is correct |
12 |
Correct |
13 ms |
31580 KB |
Output is correct |
13 |
Correct |
15 ms |
31836 KB |
Output is correct |
14 |
Correct |
14 ms |
31836 KB |
Output is correct |
15 |
Correct |
14 ms |
31832 KB |
Output is correct |
16 |
Correct |
15 ms |
31836 KB |
Output is correct |
17 |
Correct |
14 ms |
31844 KB |
Output is correct |
18 |
Correct |
14 ms |
31884 KB |
Output is correct |
19 |
Correct |
15 ms |
31832 KB |
Output is correct |
20 |
Correct |
14 ms |
31836 KB |
Output is correct |
21 |
Correct |
13 ms |
31836 KB |
Output is correct |
22 |
Correct |
91 ms |
40276 KB |
Output is correct |
23 |
Correct |
90 ms |
40380 KB |
Output is correct |
24 |
Correct |
119 ms |
42576 KB |
Output is correct |
25 |
Correct |
120 ms |
42548 KB |
Output is correct |
26 |
Correct |
104 ms |
43352 KB |
Output is correct |
27 |
Correct |
99 ms |
43528 KB |
Output is correct |
28 |
Correct |
84 ms |
41040 KB |
Output is correct |
29 |
Correct |
96 ms |
42980 KB |
Output is correct |
30 |
Correct |
122 ms |
42580 KB |
Output is correct |
31 |
Correct |
122 ms |
42584 KB |
Output is correct |
32 |
Correct |
116 ms |
42892 KB |
Output is correct |
33 |
Correct |
108 ms |
43052 KB |
Output is correct |
34 |
Correct |
123 ms |
42408 KB |
Output is correct |
35 |
Correct |
119 ms |
42836 KB |
Output is correct |
36 |
Correct |
123 ms |
42676 KB |
Output is correct |
37 |
Correct |
118 ms |
41452 KB |
Output is correct |
38 |
Correct |
114 ms |
41416 KB |
Output is correct |
39 |
Correct |
99 ms |
41464 KB |
Output is correct |
40 |
Correct |
94 ms |
41416 KB |
Output is correct |
41 |
Correct |
101 ms |
41448 KB |
Output is correct |
42 |
Correct |
93 ms |
41420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
31576 KB |
Output is correct |
2 |
Correct |
13 ms |
31576 KB |
Output is correct |
3 |
Correct |
13 ms |
31576 KB |
Output is correct |
4 |
Correct |
13 ms |
31580 KB |
Output is correct |
5 |
Correct |
12 ms |
31580 KB |
Output is correct |
6 |
Correct |
14 ms |
31580 KB |
Output is correct |
7 |
Correct |
13 ms |
31576 KB |
Output is correct |
8 |
Correct |
12 ms |
31580 KB |
Output is correct |
9 |
Correct |
13 ms |
31580 KB |
Output is correct |
10 |
Correct |
13 ms |
31580 KB |
Output is correct |
11 |
Correct |
11 ms |
31792 KB |
Output is correct |
12 |
Correct |
13 ms |
31580 KB |
Output is correct |
13 |
Correct |
15 ms |
31836 KB |
Output is correct |
14 |
Correct |
14 ms |
31836 KB |
Output is correct |
15 |
Correct |
14 ms |
31832 KB |
Output is correct |
16 |
Correct |
15 ms |
31836 KB |
Output is correct |
17 |
Correct |
14 ms |
31844 KB |
Output is correct |
18 |
Correct |
14 ms |
31884 KB |
Output is correct |
19 |
Correct |
15 ms |
31832 KB |
Output is correct |
20 |
Correct |
14 ms |
31836 KB |
Output is correct |
21 |
Correct |
13 ms |
31836 KB |
Output is correct |
22 |
Correct |
229 ms |
53564 KB |
Output is correct |
23 |
Correct |
208 ms |
54096 KB |
Output is correct |
24 |
Correct |
240 ms |
57684 KB |
Output is correct |
25 |
Correct |
402 ms |
68580 KB |
Output is correct |
26 |
Correct |
220 ms |
53840 KB |
Output is correct |
27 |
Correct |
395 ms |
68688 KB |
Output is correct |
28 |
Correct |
386 ms |
68948 KB |
Output is correct |
29 |
Correct |
202 ms |
53980 KB |
Output is correct |
30 |
Correct |
199 ms |
48816 KB |
Output is correct |
31 |
Correct |
208 ms |
50604 KB |
Output is correct |
32 |
Correct |
352 ms |
64976 KB |
Output is correct |
33 |
Correct |
194 ms |
49152 KB |
Output is correct |
34 |
Correct |
10 ms |
31576 KB |
Output is correct |
35 |
Correct |
11 ms |
31580 KB |
Output is correct |
36 |
Correct |
11 ms |
31580 KB |
Output is correct |
37 |
Correct |
11 ms |
31760 KB |
Output is correct |
38 |
Correct |
13 ms |
31800 KB |
Output is correct |
39 |
Correct |
12 ms |
31836 KB |
Output is correct |
40 |
Correct |
12 ms |
31936 KB |
Output is correct |
41 |
Correct |
198 ms |
48792 KB |
Output is correct |
42 |
Correct |
218 ms |
50608 KB |
Output is correct |
43 |
Correct |
388 ms |
64952 KB |
Output is correct |
44 |
Correct |
209 ms |
49008 KB |
Output is correct |
45 |
Correct |
114 ms |
41368 KB |
Output is correct |
46 |
Correct |
122 ms |
41416 KB |
Output is correct |
47 |
Correct |
98 ms |
41420 KB |
Output is correct |
48 |
Correct |
101 ms |
41412 KB |
Output is correct |
49 |
Correct |
104 ms |
41424 KB |
Output is correct |
50 |
Correct |
112 ms |
41424 KB |
Output is correct |
51 |
Correct |
669 ms |
81068 KB |
Output is correct |
52 |
Correct |
661 ms |
80952 KB |
Output is correct |
53 |
Correct |
527 ms |
81020 KB |
Output is correct |
54 |
Correct |
537 ms |
81068 KB |
Output is correct |
55 |
Correct |
486 ms |
81072 KB |
Output is correct |
56 |
Correct |
91 ms |
40276 KB |
Output is correct |
57 |
Correct |
90 ms |
40380 KB |
Output is correct |
58 |
Correct |
119 ms |
42576 KB |
Output is correct |
59 |
Correct |
120 ms |
42548 KB |
Output is correct |
60 |
Correct |
104 ms |
43352 KB |
Output is correct |
61 |
Correct |
99 ms |
43528 KB |
Output is correct |
62 |
Correct |
84 ms |
41040 KB |
Output is correct |
63 |
Correct |
96 ms |
42980 KB |
Output is correct |
64 |
Correct |
122 ms |
42580 KB |
Output is correct |
65 |
Correct |
122 ms |
42584 KB |
Output is correct |
66 |
Correct |
116 ms |
42892 KB |
Output is correct |
67 |
Correct |
108 ms |
43052 KB |
Output is correct |
68 |
Correct |
123 ms |
42408 KB |
Output is correct |
69 |
Correct |
119 ms |
42836 KB |
Output is correct |
70 |
Correct |
123 ms |
42676 KB |
Output is correct |
71 |
Correct |
118 ms |
41452 KB |
Output is correct |
72 |
Correct |
114 ms |
41416 KB |
Output is correct |
73 |
Correct |
99 ms |
41464 KB |
Output is correct |
74 |
Correct |
94 ms |
41416 KB |
Output is correct |
75 |
Correct |
101 ms |
41448 KB |
Output is correct |
76 |
Correct |
93 ms |
41420 KB |
Output is correct |
77 |
Correct |
764 ms |
87804 KB |
Output is correct |
78 |
Correct |
847 ms |
87888 KB |
Output is correct |
79 |
Correct |
663 ms |
92240 KB |
Output is correct |
80 |
Correct |
726 ms |
92452 KB |
Output is correct |
81 |
Correct |
713 ms |
89784 KB |
Output is correct |
82 |
Correct |
695 ms |
91368 KB |
Output is correct |
83 |
Correct |
833 ms |
87800 KB |
Output is correct |
84 |
Correct |
763 ms |
87996 KB |
Output is correct |
85 |
Correct |
716 ms |
89052 KB |
Output is correct |
86 |
Correct |
702 ms |
87380 KB |
Output is correct |
87 |
Correct |
678 ms |
88180 KB |
Output is correct |
88 |
Correct |
618 ms |
90724 KB |
Output is correct |