#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 r,c,n,q;
int x[200005],y[200005],nxt[200005][20];
map<int,set<pii>> v;
int main(){
r=readint(); c=readint(); n=readint();
for(int i=1;i<=n;i++){
x[i]=readint(); y[i]=readint();
v[x[i]].emplace(y[i],i);
}
for(int i=1;i<=n;i++){
auto it=v[x[i]+1].lower_bound(mp(y[i],-1));
if(it==v[x[i]+1].end()) nxt[i][0]=0;
else nxt[i][0]=it->se;
}
for(int j=1;j<20;j++){
for(int i=1;i<=n;i++){
nxt[i][j]=nxt[nxt[i][j-1]][j-1];
}
}
q=readint();
while(q--){
int x1=readint(),y1=readint(),x2=readint(),y2=readint();
if(x1>x2||y1>y2){
printf("No\n");
continue;
}
if(x1==x2){
printf("Yes\n");
continue;
}
auto it=v[x1].lower_bound(mp(y1,-1));
if(it==v[x1].end()){
printf("No\n");
continue;
}
int idx=it->se;
for(int i=19;i>=0;i--){
if(((x2-x1-1)>>i)&1) idx=nxt[idx][i];
}
if(idx!=0&&y[idx]<=y2) printf("Yes\n");
else printf("No\n");
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5204 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
5 ms |
5208 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
3 ms |
4972 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
153 ms |
29012 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
146 ms |
28952 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
152 ms |
28536 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
152 ms |
29100 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
229 ms |
39236 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
219 ms |
39292 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
236 ms |
39564 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
247 ms |
39464 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
233 ms |
39508 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
323 ms |
45360 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
5208 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
4 ms |
5272 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
6 ms |
5976 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
4 ms |
5212 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
5 ms |
5320 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
4 ms |
5132 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
447 ms |
46928 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
373 ms |
41132 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
250 ms |
39504 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
595 ms |
58072 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
404 ms |
45996 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
266 ms |
39536 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
311 ms |
39392 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
260 ms |
39304 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
497 ms |
45448 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
434 ms |
45704 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
552 ms |
51840 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
208 ms |
39416 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
211 ms |
39508 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
369 ms |
39492 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
217 ms |
39316 KB |
200000 token(s): yes count is 129674, no count is 70326 |