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. 富文本编辑器summernote的基本使用

    summernote比较突出的优点就是能保持复制过来的东西的原有样式,并且比较流畅. 官方文档地址:https://summernote.org/getting-started 我是用到cdn引入 & ...

  2. 7专题总结-高频题high frequency

    Outline . Single Number I, II, III . Majority Number I, II, III . Best Time to Buy and Sale Stock I, ...

  3. IdentityServer4专题之二:OpenID介绍

    1.基于概念 OpenId是一个以用户为中心的数字身份识别框架,它具有开放.分散.自由等特性.OpenId的创建是基于这样一个概念:我们可以通过URI(或者URL网址)来识别一个网站.同样,我们也可以 ...

  4. 1-3SpringBoot之Controller使用

    Controller的使用 @Controller 处理http请求 @RestController Spring4之后新加的注解,原来返回json需要@ResponseBody配合@Controll ...

  5. PHP几个快速读取大文件例子

    PHP几个快速读取大文件例子 感谢 把我给崩了 的投递 时间:2014-10-16 来源:三联 在PHP中,对于文件的读取时,最快捷的方式莫过于使用一些诸如file.file_get_contents ...

  6. 命令行添加删除tomcat服务

    在进行项目布署的时候,有时候我们需要重新添加或者卸载tomcat服务,这里,我们可以在命令提示符下进行操作,步骤如下:1.开始—运行,敲入cmd,回车打开命令提示符.2.进行tomcat所在盘符,如d ...

  7. python进阶强化学习

    最近学习了慕课的python进阶强化训练,将学习的内容记录到这里,同时也增加了很多相关知识. 主要分为以下九个模块: 基本使用 迭代器和生成器 字符串 文件IO操作 自定义类和类的继承 函数装饰器和类 ...

  8. 基于Python的大数据的分页模型代码

    最近在写一个cmdb系统的分页,尽管Django本身有分页的模块儿,但是还是想实现一下自己心中想的分页的一种逻辑 因为,在我们工作当中,当我们的数据量超级大的时候,其实我们每次分页查询都不必将所有的数 ...

  9. 使用gulp 进行ES6开发

    使用gulp 进行ES6开发 一.新建项目 项目结构如下: /app -- /js -- /css /dist -- /js -- /css -- index.html gulpfile.js 我们的 ...

  10. JS取整方法

    1.toFixed方法 定义:toFixed() 方法可把 Number 四舍五入为指定小数位数的数字. 例如:将数据Num保留2位小数,则表示为:toFixed(Num):但是其四舍五入的规则与数学 ...