hdoj Conturbatio 5480 (数组模拟+技巧) 好题
来源:互联网 发布:淘宝首页添加热点 编辑:程序博客网 时间:2024/05/21 21:04
Conturbatio
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 586 Accepted Submission(s): 274
Problem 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 T , meaning that there are T test cases.
Every test cases begin with four integersn,m,K,Q .
K is the number of Rook, Q is the number of queries.
ThenK lines follow, each contain two integers x,y describing the coordinate of Rook.
ThenQ lines follow, each contain four integers x1,y1,x2,y2 describing the left-down and right-up coordinates of query.
1≤n,m,K,Q≤100,000 .
1≤x≤n,1≤y≤m .
1≤x1≤x2≤n,1≤y1≤y2≤m .
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
YesNoYesHintHuge input, scanf recommended.题目大意:有t组测试数据,每组给一个n * m的矩形棋盘格子,棋盘内有很多车(x, y),每个车的攻击范围是这个车所在的行x和列y,共有K辆车,然后有Q次询问,每次询问给一个矩形(四个数描述矩形,左下角和右上角),问给的矩形的每个格子都能否被车攻击,是就输出“Yes”,否则“No”。//http://blog.csdn.net/Royecode/article/details/48877225,参考的大神的博客//机智的解法 ,参考大神的 #include<stdio.h>#include<string.h>#include<algorithm>#define N 100010using namespace std;int row[N],col[N];int main(){int t,i;scanf("%d",&t);while(t--){memset(row,0,sizeof(row));memset(col,0,sizeof(col));int n,m,k,q;scanf("%d%d%d%d",&n,&m,&k,&q);for(i=0;i<k;i++){int x,y;scanf("%d%d",&x,&y);row[x]=col[y]=1;//将车的点的横纵坐标标记为1. }for(i=1;i<=n;i++)//将车所在的行全标记为1。 if(row[i])row[i]+=row[i-1];for(i=1;i<=m;i++)//将车所在的列全标记为1. if(col[i])col[i]+=col[i-1];for(i=0;i<q;i++){int x1,x2,y1,y2;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
- hdoj Conturbatio 5480 (数组模拟+技巧) 好题
- HDOJ 5480 Conturbatio
- hdoj 5480 Conturbatio 【思维】
- hdoj 5480 Conturbatio (思维)
- 【HDU】-5480-Conturbatio(思维,好)
- hdu 5480 Conturbatio【模拟】
- HDU 5480 Conturbatio(树状数组)
- HDU 5480 Conturbatio 树状数组
- HDU 5480 Conturbatio(二维树状数组维护区间和)
- hdoj Work 5326 (并查集+技巧) 好题
- hdoj Arithmetic Sequence 5400 (构造等差数列+技巧) 好题
- hdoj Reorder the Books 5500 (技巧) 好题
- hdoj Matrix 5671 (矩阵模拟&技巧)
- hdu5480 Conturbatio(树状数组)
- LA 3029 - City Game (模拟&技巧)好题
- ZOJ - 3872 Beauty of Array (技巧&模拟)好题
- HDU 5480 Conturbatio(前缀和)
- hdoj Kingdom of Black and White 5583 (模拟&&DP) 好题
- 合成一个新的dateframe
- iOS开发:绘制像素到屏幕
- SQL Server 复制:事务发布
- 【IOS 开发学习总结-OC-43】★ios开发——UIButton(按钮)与 UISwitch(开关按钮)
- Javascript获取属性的值以及比较值
- hdoj Conturbatio 5480 (数组模拟+技巧) 好题
- npm 安装 appium 更换源的方式安装
- [每日一答] [20151011] 如何在Python2.7版本中安装pip程序呢?
- docker-registry2(docker-distribution)环境搭建
- POJ - 1426 Find The Multiple(15.10.10 搜索专题)bfs
- Linux内核工程导论——内核为何使用C语言
- android studio导入os库
- HDU 4770 Lights Against Dudely(暴力枚举) 2013杭州现场赛
- OpenCv:Mat矩阵的初始化