#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
#define _ << " " <<
const lo inf = 1000000000;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,a[li],k,flag,t,x[li],y[li],r,c,xs[li],xh[li],ys[li],yh[li],fa[li][32];
int cev;
string s;
vector<int> v,vv[li];
int32_t main(void){
fio();
cin>>r>>c>>n;
FOR{
cin>>x[i]>>y[i];
v.pb(x[i]);
}
cin>>t;
for(int i=1;i<=t;i++){
cin>>xs[i]>>ys[i]>>xh[i]>>yh[i];
}
sort(v.begin(),v.end());
int sayac=0;
map<int,int> mpp;
for(int i=0;i<(int)v.size();i++){
if(i==0 || v[i]!=v[i-1]){
sayac++;
mpp[v[i]]=sayac;
}
}
map<pair<int,int>,int> mapp;
for(int i=1;i<=n;i++){
vv[mpp[x[i]]].pb(y[i]);
mapp[{x[i],y[i]}]=i;
}
for(int i=1;i<=sayac;i++)sort(vv[i].begin(),vv[i].end());
for(int i=1;i<=n;i++){
int at=mpp[x[i]+1];
int tut=lower_bound(vv[at].begin(),vv[at].end(),y[i])-vv[at].begin();
if(tut==(int)vv[at].size())fa[i][0]=0;
else fa[i][0]=mapp[{x[i]+1,vv[at][tut]}];
//~ cout<<i _ fa[i][0]<<endl;
}
for(int j=1;j<=20;j++){
FOR fa[i][j]=fa[fa[i][j-1]][j-1];
}
for(int i=1;i<=t;i++){
if(xh[i]==xs[i]){
if(ys[i]<=yh[i]){cout<<"Yes\n";continue;}
cout<<"No\n";continue;
}
if(xh[i]-xs[i]>n){cout<<"No\n";continue;}
int at=mpp[xs[i]];
int tut=lower_bound(vv[at].begin(),vv[at].end(),ys[i])-vv[at].begin();
if(tut==(int)vv[at].size()){cout<<"No\n";continue;}
int node=mapp[{xs[i],vv[at][tut]}];
//~ cout<<node<<" ()() \n";
for(int j=20;j>=0;j--){
if(fa[node][j]==0 || x[fa[node][j]]>=xh[i])continue;
node=fa[node][j];
//~ cout<<fa[node][j] _ node _ j<<" AA\n";
}
//~ cout<<i _ node _ x[node] _ y[node]<<endl;
if(x[node]!=xh[i]-1){cout<<"No\n";continue;}
at=mpp[x[node]];
tut=lower_bound(vv[at].begin(),vv[at].end(),y[node])-vv[at].begin();
if(tut==(int)vv[at].size()){cout<<"No\n";continue;}
if(vv[at][tut]>yh[i]){cout<<"No\n";continue;}
cout<<"Yes\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
30040 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
11 ms |
30040 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
9 ms |
24664 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
309 ms |
95688 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
309 ms |
95684 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
328 ms |
94916 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
280 ms |
95684 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
445 ms |
98632 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
503 ms |
98776 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
516 ms |
98760 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
552 ms |
99524 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
606 ms |
98220 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
705 ms |
104644 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
29700 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
11 ms |
29716 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
13 ms |
30300 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
10 ms |
29616 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
13 ms |
24156 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
10 ms |
26036 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
932 ms |
100960 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
759 ms |
97988 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
572 ms |
94108 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
1158 ms |
112328 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
765 ms |
103624 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
609 ms |
100564 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
583 ms |
102080 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
583 ms |
100044 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
933 ms |
105952 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
1004 ms |
107708 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
1020 ms |
111024 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
459 ms |
100040 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
481 ms |
99988 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
637 ms |
100804 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
510 ms |
99964 KB |
200000 token(s): yes count is 129674, no count is 70326 |