Conturbatio

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 232    Accepted Submission(s): 108

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?
 
Input
The first line of the input is a integer T,
meaning that there are T test
cases.



Every test cases begin with four integers n,m,K,Q.

K is
the number of Rook, Q is
the number of queries.



Then K lines
follow, each contain two integers x,y describing
the coordinate of Rook.



Then Q 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.
 
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
Hint
Huge input, scanf recommended.

题意是一个棋盘上有很多车,车可以攻击他所属的一行或一列,包括它自己所在的位置。现在有很多询问,每次询问给定一个棋盘内部的矩形,问矩形内部的所有格子是否都被车攻击到?

对自己的智商感到不断怀疑系列。。。判断中间有没有零,求和啊

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#pragma warning(disable:4996)
using namespace std; int row[100005];
int column[100005]; int main()
{
int test,i,j,flag1,flag2;
int n,m,k,q,x,y,x1,x2,y1,y2; scanf("%d",&test); while(test--)
{
scanf("%d%d%d%d",&n,&m,&k,&q); memset(row,0,sizeof(row));
memset(column,0,sizeof(column)); for(i=1;i<=k;i++)
{
scanf("%d%d",&x,&y);
row[x]=1;
column[y]=1;
}
for(i=1;i<=n;i++)
{
row[i]=row[i]+row[i-1];
}
for(i=1;i<=m;i++)
{
column[i]=column[i]+column[i-1];
}
for(i=1;i<=q;i++)
{
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
if(x2-x1+1==row[x2]-row[x1-1]||y2-y1+1==column[y2]-column[y1-1])
{
puts("Yes");
}
else
{
puts("No");
}
}
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

HDU 5480:Conturbatio 前缀和的更多相关文章

  1. hdu 5480 Conturbatio 线段树 单点更新,区间查询最小值

    Conturbatio Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=54 ...

  2. hdu 5480(维护前缀和+思路题)

    Conturbatio Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  3. HDU 5480 Conturbatio

    区间求和不更新,开个数组记录一下前缀和就可以了 #include<cstdio> #include<cstring> #include<cmath> #includ ...

  4. hdu 5480(前缀和)

    题意:如果一个点,则这点的横竖皆被占领,询问矩阵是否全被占领. 思路:将被占领的x,y标记为1,用x表示1 - i的和 如果x轴的差为 x2 - x1 + 1则表示全被占领,y轴同理 #include ...

  5. HDU 1358 (所有前缀中的周期串) Period

    题意: 给出一个字符串,在所有长度大于1的前缀中,求所有的周期至少为2的周期串,并输出一个周期的长度以及周期的次数. 分析: 有了上一题 HDU 3746 的铺垫,这道题就很容易解决了 把next求出 ...

  6. HDU 5714 拍照 前缀和

    拍照 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5714 Description 小明在旅游的路上看到了一条美丽的河,河上有许多船只,有的船只向左 ...

  7. Coprime Sequence (HDU 6025)前缀和与后缀和的应用

    题意:给出一串数列,这串数列的gcd为1,要求取出一个数使取出后的数列gcd最大. 题解:可以通过对数列进行预处理,求出从下标为1开始的数对于前面的数的gcd(数组从下标0开始),称为前缀gcd,再以 ...

  8. hdu 5776 sum 前缀和

    sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submi ...

  9. HDU - 1588 矩阵前缀和

    题意:给定\(k,b,n,m\),求\(\sum_{i=0}^{n-1}f(g(i))\) 其中\(f(i)=f(i-1)+f(i-2),f(1)=1,f(0)=0\),\(g(i)=k*i+b\) ...

随机推荐

  1. 一、iBatis进行分页查询

    1.ibatis理解: iBatis属于半自动化的ORM框架,我们需要编写SQL语句,由iBatis进行数据库访问,返回结果.而iBatis可以为我们做的更多,比如对查询参数集合.结果.分页查询.事务 ...

  2. H5禁止底部横向滚动条,使一个元素居中

    1.禁止底部横向滚动条 选择元素设置样式 { overflow-y:auto; overflow-x:hidden } 2.元素居中 { margin-left:auto ; margin-right ...

  3. Vue--爬坑

    1.路由变化页面数据不刷新问题: 出现这种情况是因为依赖路由的params参数获取写在created生命周期里面,因为相同路由二次甚至多次加载的关系 没有达到监听,退出页面再进入另一个文章页面并不会运 ...

  4. 如何在SecureCRT中上传文件到linux服务器上

    1.使用yum安装运行命令sudo yum install lrzsz(默认使没有安装运行命令的) 2.上传命令rz  下载命令sz  

  5. Mybatis入门(五)属性名和字段名不一致解决

    在学Mybatis的时候都需要创建一个实体类,但创建实体类的变量必须和数据库的一样,这章就来解决这个有趣的问题 目录: 问题是这样: 输出的结果是: password为空,这就很难受: 解决方法: 第 ...

  6. Day1-D-CF-1144C

    简述:给你一个数组,判断是否能拆分成2个数组,一个递增一个递减,若不行输出No,可以就Yes并分别输出 思路:统计每个数出现的次数,若有大于2的肯定无法组成严格单调,这样就只需要将出现两次的组成递,剩 ...

  7. app开屏广告

    最近公司有个需求需要做app开屏广告(跳转到不同的页面)--下面是app开屏广告的处理 1.管理后台效果图 (1)广告链接--商品详情 (2)广告链接--关联模块 (3)广告链接--消息富文本 (4) ...

  8. 车林通购车之家--购车计算器模块js实现

    //jsq-nav.twig <ul class="switch-nav db-tags bgfff clearfix"> <li id="qk&quo ...

  9. 084、Java数组之实现数组复制

    01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...

  10. JavaScript 字符编码

    JavaScript 字符编码 JavaScript 遵循 Unicode 字符编码规则.Unicode 字符集中每个字符使用 2 个字节来表示,这意味着用户可以使用中文来命名 Java)Script ...