Conturbatio
来源:互联网 发布:mysql-python和mysqldb 编辑:程序博客网 时间:2024/05/16 03:31
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
22 2 1 21 11 1 1 22 1 2 22 2 2 11 11 22 1 2 2
Sample Output
YesNoYes
Hint
Huge input, scanf recommended.在一个n*m的方格内,有K个车,它可以攻击它所在的行和列,包括它自己,给你4个点,代表一个矩形的左下和右上的点,问你它是否可以攻击完矩形内的所有方格:思路,思维题,看代码,自己画图理解;#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int row[100009],col[100009];int main(){int t,n,m,k,q,x1,x2,y1,y2,i,j;int a,b;scanf("%d",&t);while(t--){memset(row,0,sizeof(row));memset(col,0,sizeof(col));scanf("%d%d%d%d",&n,&m,&k,&q);for(i=0;i<k;i++){scanf("%d%d",&a,&b);row[a]=1;col[b]=1;}for(i=1;i<=n;i++)if(row[i]) row[i]+=row[i-1];for(i=1;i<=m;i++)if(col[i]) col[i]+=col[i-1];for(i=0;i<q;i++){scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(row[x2]>=x2-x1+1||col[y2]>=y2-y1+1)printf("Yes\n");elseprintf("No\n");}}return 0;}
0 0
- Conturbatio
- Conturbatio
- Conturbatio
- HDU5480: Conturbatio
- 【NJUST5480】Conturbatio
- HDU 5480 Conturbatio
- hdu5480 Conturbatio(树状数组)
- Hdu 5480 Conturbatio
- BestCoder#57 Conturbatio
- HDOJ 5480 Conturbatio
- hdu 5480Conturbatio
- HDU 5480 Conturbatio
- hdu 5480 Conturbatio(水)
- hdu 5480 Conturbatio【模拟】
- hdoj 5480 Conturbatio 【思维】
- hdu 5480 Conturbatio
- 【HDU 5480 Conturbatio】
- 杭电5480Conturbatio
- maven 的pom出现web.xml is missing and <failOnMissingWebXml> is set to true
- springmvc基于xml文件的配置方式
- FZU 2180 双向BFS
- 37. Sudoku Solver
- 2003系统配置IIS+CGI环境,装active perl提示安装不了的解决办法
- Conturbatio
- 常用控件之--------UILabel
- Fragment介绍
- ListView复用导致图片错乱及闪烁问题
- 为什么使用dojo?dojo与jquery有什么不同?dojo适合什么开发场景?
- JS常见插件
- 1-HTML元素 属性 格式化
- 38. Count and Say
- 2-HTML5样式、链接和表格