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