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. tomcat安装apr报错解决

    参考http://www.cnblogs.com/nuccch/p/7598361.html 1.no c complie 安装gcc解决 2.rm: cannot remove `libtoolT' ...

  2. Mac安装jdk

    jdk:https://blog.csdn.net/zw235345721/article/details/78702254 mysql:https://www.jianshu.com/p/fd3aa ...

  3. ajax请求QQ音乐

    搜索歌曲 function go() {                var val = document.getElementById("name").value;       ...

  4. python列表元组 魔法方法

    1.元祖 count()    统计某个字符串的出现次数 tuple.count('22')    返回一个整数 index()    获取某个值出现的位置 2.列表 字符串可以直接转换列表    l ...

  5. python中判断素数的函数

    来看这一种判断素数(质数)的函数: form math import sart def is_prime(n): if n==1: return False for i in range(2, int ...

  6. 怎样快速高效的定义Django的序列化器

    1.使用Serializer方法自己创建一个序列化器 先写一个简单的例子 class BookInfoSerializer(serializers.Serializer): ""& ...

  7. 蓝牙 BLE 协议学习: 000-有关概念介绍

    背景 在学校内就用过蓝牙技术参加过比赛(并拿了奖):而蓝牙作为物联网中比较常见的协议,有必要进行深入的学习.此后的文章会以 ble(v4.0) 进行学习. 介绍 蓝牙技术最初由电信巨头爱立信公司于 1 ...

  8. hostPath Volume【转】

    hostPath Volume 的作用是将 Docker Host 文件系统中已经存在的目录 mount 给 Pod 的容器.大部分应用都不会使用 hostPath Volume,因为这实际上增加了 ...

  9. js - 获取当前年月日

    var date = new Date(); date .getYear(); //获取当前年份(2位) date .getFullYear(); //获取完整的年份(4位) date .getMon ...

  10. centos安装sass环境必看

    首先了解一下  sass是什么?! sass号称“世界上最成熟.最稳定.最强大的专业级css扩展语言” ,sass基于于Ruby语言开发而成,因此安装sass前需要安装Ruby, 1.安装ruby y ...