#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
ll readint(){
ll x=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,m,q;
int mini[4000005],tag[4000005],ans[500005];
vector<int> seg[500005];
vector<pii> qry[500005];
void push(int id){
chkmax(mini[id<<1],tag[id]);
chkmax(mini[id<<1|1],tag[id]);
chkmax(tag[id<<1],tag[id]);
chkmax(tag[id<<1|1],tag[id]);
tag[id]=0;
}
void change(int id,int l,int r,int ql,int qr,int v){
if(ql<=l&&r<=qr){
chkmax(tag[id],v);
chkmax(mini[id],v);
push(id);
return;
}
push(id);
int mid=(l+r)/2;
if(qr<=mid) change(id<<1,l,mid,ql,qr,v);
else if(ql>mid) change(id<<1|1,mid+1,r,ql,qr,v);
else change(id<<1,l,mid,ql,qr,v),change(id<<1|1,mid+1,r,ql,qr,v);
mini[id]=min(mini[id<<1],mini[id<<1|1]);
}
int query(int id,int l,int r,int ql,int qr){
if(ql<=l&&r<=qr) return mini[id];
push(id);
int mid=(l+r)/2;
int ret=0;
if(qr<=mid) ret=query(id<<1,l,mid,ql,qr);
else if(ql>mid) ret=query(id<<1|1,mid+1,r,ql,qr);
else ret=min(query(id<<1,l,mid,ql,qr),query(id<<1|1,mid+1,r,ql,qr));
mini[id]=min(mini[id<<1],mini[id<<1|1]);
return ret;
}
int main(){
n=readint(); m=readint(); q=readint();
int l,r;
for(int i=1;i<=m;i++){
l=readint(); r=readint();
seg[r].pb(l);
}
for(int i=1;i<=q;i++){
l=readint(); r=readint();
qry[r].pb(mp(l,i));
}
for(int i=1;i<=n;i++){
for(auto p:seg[i]) change(1,1,n,p,i,p);
for(auto p:qry[i]) ans[p.se]=(query(1,1,n,p.fi,i)>=p.fi?1:0);
}
for(int i=1;i<=q;i++){
if(ans[i]==0) printf("NO\n");
else printf("YES\n");
}
printf("\n");
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
25244 KB |
Output is correct |
2 |
Correct |
7 ms |
25228 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
4 |
Correct |
10 ms |
25176 KB |
Output is correct |
5 |
Correct |
6 ms |
25180 KB |
Output is correct |
6 |
Correct |
8 ms |
25220 KB |
Output is correct |
7 |
Correct |
6 ms |
25180 KB |
Output is correct |
8 |
Correct |
6 ms |
25176 KB |
Output is correct |
9 |
Correct |
6 ms |
25180 KB |
Output is correct |
10 |
Correct |
6 ms |
25180 KB |
Output is correct |
11 |
Correct |
6 ms |
25232 KB |
Output is correct |
12 |
Correct |
6 ms |
25180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
25244 KB |
Output is correct |
2 |
Correct |
7 ms |
25228 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
4 |
Correct |
10 ms |
25176 KB |
Output is correct |
5 |
Correct |
6 ms |
25180 KB |
Output is correct |
6 |
Correct |
8 ms |
25220 KB |
Output is correct |
7 |
Correct |
6 ms |
25180 KB |
Output is correct |
8 |
Correct |
6 ms |
25176 KB |
Output is correct |
9 |
Correct |
6 ms |
25180 KB |
Output is correct |
10 |
Correct |
6 ms |
25180 KB |
Output is correct |
11 |
Correct |
6 ms |
25232 KB |
Output is correct |
12 |
Correct |
6 ms |
25180 KB |
Output is correct |
13 |
Correct |
7 ms |
25436 KB |
Output is correct |
14 |
Correct |
8 ms |
25444 KB |
Output is correct |
15 |
Correct |
8 ms |
25256 KB |
Output is correct |
16 |
Correct |
13 ms |
25308 KB |
Output is correct |
17 |
Correct |
11 ms |
25436 KB |
Output is correct |
18 |
Correct |
7 ms |
25436 KB |
Output is correct |
19 |
Correct |
7 ms |
25436 KB |
Output is correct |
20 |
Correct |
7 ms |
25436 KB |
Output is correct |
21 |
Correct |
9 ms |
25436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
25244 KB |
Output is correct |
2 |
Correct |
7 ms |
25228 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
4 |
Correct |
10 ms |
25176 KB |
Output is correct |
5 |
Correct |
6 ms |
25180 KB |
Output is correct |
6 |
Correct |
8 ms |
25220 KB |
Output is correct |
7 |
Correct |
6 ms |
25180 KB |
Output is correct |
8 |
Correct |
6 ms |
25176 KB |
Output is correct |
9 |
Correct |
6 ms |
25180 KB |
Output is correct |
10 |
Correct |
6 ms |
25180 KB |
Output is correct |
11 |
Correct |
6 ms |
25232 KB |
Output is correct |
12 |
Correct |
6 ms |
25180 KB |
Output is correct |
13 |
Correct |
7 ms |
25436 KB |
Output is correct |
14 |
Correct |
8 ms |
25444 KB |
Output is correct |
15 |
Correct |
8 ms |
25256 KB |
Output is correct |
16 |
Correct |
13 ms |
25308 KB |
Output is correct |
17 |
Correct |
11 ms |
25436 KB |
Output is correct |
18 |
Correct |
7 ms |
25436 KB |
Output is correct |
19 |
Correct |
7 ms |
25436 KB |
Output is correct |
20 |
Correct |
7 ms |
25436 KB |
Output is correct |
21 |
Correct |
9 ms |
25436 KB |
Output is correct |
22 |
Correct |
146 ms |
38168 KB |
Output is correct |
23 |
Correct |
147 ms |
38456 KB |
Output is correct |
24 |
Correct |
171 ms |
39700 KB |
Output is correct |
25 |
Correct |
298 ms |
45460 KB |
Output is correct |
26 |
Correct |
141 ms |
38228 KB |
Output is correct |
27 |
Correct |
296 ms |
45652 KB |
Output is correct |
28 |
Correct |
308 ms |
45740 KB |
Output is correct |
29 |
Correct |
125 ms |
37276 KB |
Output is correct |
30 |
Correct |
79 ms |
37204 KB |
Output is correct |
31 |
Correct |
99 ms |
38044 KB |
Output is correct |
32 |
Correct |
229 ms |
44620 KB |
Output is correct |
33 |
Correct |
77 ms |
37496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
25180 KB |
Output is correct |
2 |
Correct |
6 ms |
25432 KB |
Output is correct |
3 |
Correct |
6 ms |
25216 KB |
Output is correct |
4 |
Correct |
6 ms |
25180 KB |
Output is correct |
5 |
Correct |
9 ms |
25436 KB |
Output is correct |
6 |
Correct |
7 ms |
25284 KB |
Output is correct |
7 |
Correct |
7 ms |
25436 KB |
Output is correct |
8 |
Correct |
78 ms |
37304 KB |
Output is correct |
9 |
Correct |
97 ms |
38220 KB |
Output is correct |
10 |
Correct |
234 ms |
44736 KB |
Output is correct |
11 |
Correct |
84 ms |
37272 KB |
Output is correct |
12 |
Correct |
129 ms |
36304 KB |
Output is correct |
13 |
Correct |
106 ms |
36320 KB |
Output is correct |
14 |
Correct |
69 ms |
36620 KB |
Output is correct |
15 |
Correct |
67 ms |
36176 KB |
Output is correct |
16 |
Correct |
69 ms |
36464 KB |
Output is correct |
17 |
Correct |
76 ms |
36176 KB |
Output is correct |
18 |
Correct |
745 ms |
79660 KB |
Output is correct |
19 |
Correct |
717 ms |
79356 KB |
Output is correct |
20 |
Correct |
479 ms |
80448 KB |
Output is correct |
21 |
Correct |
468 ms |
79440 KB |
Output is correct |
22 |
Correct |
497 ms |
78636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
25244 KB |
Output is correct |
2 |
Correct |
7 ms |
25228 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
4 |
Correct |
10 ms |
25176 KB |
Output is correct |
5 |
Correct |
6 ms |
25180 KB |
Output is correct |
6 |
Correct |
8 ms |
25220 KB |
Output is correct |
7 |
Correct |
6 ms |
25180 KB |
Output is correct |
8 |
Correct |
6 ms |
25176 KB |
Output is correct |
9 |
Correct |
6 ms |
25180 KB |
Output is correct |
10 |
Correct |
6 ms |
25180 KB |
Output is correct |
11 |
Correct |
6 ms |
25232 KB |
Output is correct |
12 |
Correct |
6 ms |
25180 KB |
Output is correct |
13 |
Correct |
7 ms |
25436 KB |
Output is correct |
14 |
Correct |
8 ms |
25444 KB |
Output is correct |
15 |
Correct |
8 ms |
25256 KB |
Output is correct |
16 |
Correct |
13 ms |
25308 KB |
Output is correct |
17 |
Correct |
11 ms |
25436 KB |
Output is correct |
18 |
Correct |
7 ms |
25436 KB |
Output is correct |
19 |
Correct |
7 ms |
25436 KB |
Output is correct |
20 |
Correct |
7 ms |
25436 KB |
Output is correct |
21 |
Correct |
9 ms |
25436 KB |
Output is correct |
22 |
Correct |
94 ms |
30032 KB |
Output is correct |
23 |
Correct |
110 ms |
30020 KB |
Output is correct |
24 |
Correct |
157 ms |
35660 KB |
Output is correct |
25 |
Correct |
146 ms |
35576 KB |
Output is correct |
26 |
Correct |
117 ms |
36908 KB |
Output is correct |
27 |
Correct |
101 ms |
36944 KB |
Output is correct |
28 |
Correct |
101 ms |
34640 KB |
Output is correct |
29 |
Correct |
101 ms |
36432 KB |
Output is correct |
30 |
Correct |
149 ms |
35652 KB |
Output is correct |
31 |
Correct |
142 ms |
35668 KB |
Output is correct |
32 |
Correct |
137 ms |
36172 KB |
Output is correct |
33 |
Correct |
111 ms |
36544 KB |
Output is correct |
34 |
Correct |
119 ms |
35272 KB |
Output is correct |
35 |
Correct |
115 ms |
35352 KB |
Output is correct |
36 |
Correct |
108 ms |
36112 KB |
Output is correct |
37 |
Correct |
117 ms |
36304 KB |
Output is correct |
38 |
Correct |
114 ms |
36356 KB |
Output is correct |
39 |
Correct |
82 ms |
36600 KB |
Output is correct |
40 |
Correct |
85 ms |
36056 KB |
Output is correct |
41 |
Correct |
82 ms |
36424 KB |
Output is correct |
42 |
Correct |
93 ms |
36088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
25244 KB |
Output is correct |
2 |
Correct |
7 ms |
25228 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
4 |
Correct |
10 ms |
25176 KB |
Output is correct |
5 |
Correct |
6 ms |
25180 KB |
Output is correct |
6 |
Correct |
8 ms |
25220 KB |
Output is correct |
7 |
Correct |
6 ms |
25180 KB |
Output is correct |
8 |
Correct |
6 ms |
25176 KB |
Output is correct |
9 |
Correct |
6 ms |
25180 KB |
Output is correct |
10 |
Correct |
6 ms |
25180 KB |
Output is correct |
11 |
Correct |
6 ms |
25232 KB |
Output is correct |
12 |
Correct |
6 ms |
25180 KB |
Output is correct |
13 |
Correct |
7 ms |
25436 KB |
Output is correct |
14 |
Correct |
8 ms |
25444 KB |
Output is correct |
15 |
Correct |
8 ms |
25256 KB |
Output is correct |
16 |
Correct |
13 ms |
25308 KB |
Output is correct |
17 |
Correct |
11 ms |
25436 KB |
Output is correct |
18 |
Correct |
7 ms |
25436 KB |
Output is correct |
19 |
Correct |
7 ms |
25436 KB |
Output is correct |
20 |
Correct |
7 ms |
25436 KB |
Output is correct |
21 |
Correct |
9 ms |
25436 KB |
Output is correct |
22 |
Correct |
146 ms |
38168 KB |
Output is correct |
23 |
Correct |
147 ms |
38456 KB |
Output is correct |
24 |
Correct |
171 ms |
39700 KB |
Output is correct |
25 |
Correct |
298 ms |
45460 KB |
Output is correct |
26 |
Correct |
141 ms |
38228 KB |
Output is correct |
27 |
Correct |
296 ms |
45652 KB |
Output is correct |
28 |
Correct |
308 ms |
45740 KB |
Output is correct |
29 |
Correct |
125 ms |
37276 KB |
Output is correct |
30 |
Correct |
79 ms |
37204 KB |
Output is correct |
31 |
Correct |
99 ms |
38044 KB |
Output is correct |
32 |
Correct |
229 ms |
44620 KB |
Output is correct |
33 |
Correct |
77 ms |
37496 KB |
Output is correct |
34 |
Correct |
7 ms |
25180 KB |
Output is correct |
35 |
Correct |
6 ms |
25432 KB |
Output is correct |
36 |
Correct |
6 ms |
25216 KB |
Output is correct |
37 |
Correct |
6 ms |
25180 KB |
Output is correct |
38 |
Correct |
9 ms |
25436 KB |
Output is correct |
39 |
Correct |
7 ms |
25284 KB |
Output is correct |
40 |
Correct |
7 ms |
25436 KB |
Output is correct |
41 |
Correct |
78 ms |
37304 KB |
Output is correct |
42 |
Correct |
97 ms |
38220 KB |
Output is correct |
43 |
Correct |
234 ms |
44736 KB |
Output is correct |
44 |
Correct |
84 ms |
37272 KB |
Output is correct |
45 |
Correct |
129 ms |
36304 KB |
Output is correct |
46 |
Correct |
106 ms |
36320 KB |
Output is correct |
47 |
Correct |
69 ms |
36620 KB |
Output is correct |
48 |
Correct |
67 ms |
36176 KB |
Output is correct |
49 |
Correct |
69 ms |
36464 KB |
Output is correct |
50 |
Correct |
76 ms |
36176 KB |
Output is correct |
51 |
Correct |
745 ms |
79660 KB |
Output is correct |
52 |
Correct |
717 ms |
79356 KB |
Output is correct |
53 |
Correct |
479 ms |
80448 KB |
Output is correct |
54 |
Correct |
468 ms |
79440 KB |
Output is correct |
55 |
Correct |
497 ms |
78636 KB |
Output is correct |
56 |
Correct |
94 ms |
30032 KB |
Output is correct |
57 |
Correct |
110 ms |
30020 KB |
Output is correct |
58 |
Correct |
157 ms |
35660 KB |
Output is correct |
59 |
Correct |
146 ms |
35576 KB |
Output is correct |
60 |
Correct |
117 ms |
36908 KB |
Output is correct |
61 |
Correct |
101 ms |
36944 KB |
Output is correct |
62 |
Correct |
101 ms |
34640 KB |
Output is correct |
63 |
Correct |
101 ms |
36432 KB |
Output is correct |
64 |
Correct |
149 ms |
35652 KB |
Output is correct |
65 |
Correct |
142 ms |
35668 KB |
Output is correct |
66 |
Correct |
137 ms |
36172 KB |
Output is correct |
67 |
Correct |
111 ms |
36544 KB |
Output is correct |
68 |
Correct |
119 ms |
35272 KB |
Output is correct |
69 |
Correct |
115 ms |
35352 KB |
Output is correct |
70 |
Correct |
108 ms |
36112 KB |
Output is correct |
71 |
Correct |
117 ms |
36304 KB |
Output is correct |
72 |
Correct |
114 ms |
36356 KB |
Output is correct |
73 |
Correct |
82 ms |
36600 KB |
Output is correct |
74 |
Correct |
85 ms |
36056 KB |
Output is correct |
75 |
Correct |
82 ms |
36424 KB |
Output is correct |
76 |
Correct |
93 ms |
36088 KB |
Output is correct |
77 |
Correct |
967 ms |
75932 KB |
Output is correct |
78 |
Correct |
954 ms |
76004 KB |
Output is correct |
79 |
Correct |
637 ms |
82516 KB |
Output is correct |
80 |
Correct |
607 ms |
82744 KB |
Output is correct |
81 |
Correct |
605 ms |
80404 KB |
Output is correct |
82 |
Correct |
695 ms |
81552 KB |
Output is correct |
83 |
Correct |
911 ms |
75844 KB |
Output is correct |
84 |
Correct |
906 ms |
75904 KB |
Output is correct |
85 |
Correct |
790 ms |
77728 KB |
Output is correct |
86 |
Correct |
726 ms |
74408 KB |
Output is correct |
87 |
Correct |
751 ms |
73852 KB |
Output is correct |
88 |
Correct |
655 ms |
80736 KB |
Output is correct |