区间求和不更新,开个数组记录一下前缀和就可以了
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; const int maxn=+;
int R[maxn],C[maxn];
int sumR[maxn],sumC[maxn]; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,m,K,Q;
memset(R,,sizeof R);
memset(C,,sizeof C);
memset(sumR,,sizeof sumR);
memset(sumC,,sizeof sumC);
scanf("%d%d%d%d",&n,&m,&K,&Q); for(int i=;i<=K;i++)
{
int x,y;
scanf("%d%d",&x,&y);
R[x]=;
C[y]=;
}
sumR[]=R[];
for(int i=;i<=n;i++) sumR[i]=sumR[i-]+R[i]; sumC[]=C[];
for(int i=;i<=m;i++) sumC[i]=sumC[i-]+C[i]; for(int i=;i<=Q;i++)
{
int x1,y1,x2,y2;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
if(sumR[x2]-sumR[x1-]==x2-(x1-)||sumC[y2]-sumC[y1-]==y2-(y1-)) printf("Yes\n");
else printf("No\n");
}
} return ;
}