Description
There are many rook on a chessboard, a rook can attack the row and column it belongs, including its own place.
There are also many queries, each query gives a rectangle on the chess board, and asks whether every grid in the rectangle will be attacked by any rook?
There are also many queries, each query gives a rectangle on the chess board, and asks whether every grid in the rectangle will be attacked by any rook?
Input
The first line of the input is a integer
, meaning that there are
test cases.
Every test cases begin with four integers





.
is the number of Rook,
is the number of queries.
Then
lines follow, each contain two integers


describing the coordinate of Rook.
Then
lines follow, each contain four integers










describing the left-down and right-up coordinates of query.
















.










.


















.


Every test cases begin with four integers









Then




Then



























































Output
For every query output "Yes" or "No" as mentioned above.
Sample Input
2 2 2 1 2 1 1 1 1 1 2 2 1 2 2 2 2 2 1 1 1 1 2 2 1 2 2
Sample Output
Yes No Yes 题意:有一个n*m的棋盘 K个车,车可以攻击它所在的一列或一行,包括自己所在位置,有Q个查询,
输入K行(x,y)表示车的坐标,然后输入Q行,每行4个数x1 y1 x2 y2分别表示矩形的左下角坐标和右上角坐 标,判断矩形内的人能否被全部攻击,是的话输出yes,不是输出no
题解:标记车的行列坐标,表示可以攻击,如果能攻击所有的行或者能攻击所有的列,那么矩形被攻陷1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37#include<cstdio> #include<cstring> int main() { int t; int hang[100010],lie[100010]; scanf("%d",&t); while(t--) { int n,m,k,q; scanf("%d%d%d%d",&n,&m,&k,&q); memset(hang,0,sizeof(hang)); memset(lie,0,sizeof(lie)); int x,y; for(int i=1;i<=k;i++) { scanf("%d%d",&x,&y); hang[x]=1; lie[y]=1;//标记车的行列坐标 } for(int i=1;i<=n;i++) { hang[i]+=hang[i-1];//累加和 算出所有车能攻击多少行 lie[i]+=lie[i-1];//能攻击的列数 } int x1,x2,y1,y2; for(int i=1;i<=q;i++) { scanf("%d%d%d%d",&x1,&y1,&x2,&y2); if(x2-x1+1==hang[x2]-hang[x1-1]||y2-y1+1==lie[y2]-lie[y1-1])
//如果所给矩形行数==车能攻击的行数 或者矩形列数==车能攻击的列数,那么没有幸存者 printf("Yes\n");
else printf("No\n"); } } return 0; }