Conturbatio
Conturbatio
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 234 Accepted Submission(s): 110
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?
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.
Huge input, scanf recommended.
题意:给你象棋中所有车的位置,每次询问矩形给你左上角和右上角的点,问这个矩形中的点是否可以被车吃完。
#include<iostream>
#include<cstdio>
#include<cstring> using namespace std; #define maxn 110008
int x[maxn], y[maxn]; int main()
{
int t, n, m, k, q, a, b, x1, x2, y1, y2;
scanf("%d", &t);
while(t--)
{
scanf("%d%d%d%d", &n, &m, &k, &q);
memset(x, 0, sizeof(x));
memset(y, 0, sizeof(y));
for(int i = 0; i < k; i++)
{
scanf("%d%d", &a, &b);
x[a] = 1;
y[b] = 1;
} for(int i = 2; i <= n; i++)
x[i] += x[i-1];
for(int i = 2; i <= m; i++)
y[i] += y[i-1]; for(int w = 0; w < q; w++)
{
int i, j;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2); if(x[x2]-x[x1-1] == x2-x1+1 || y[y2]-y[y1-1] == y2-y1+1) // 每次查询看是否矩形所在的所有行或所有列全部被车吃掉
printf("Yes\n");
else
printf("No\n");
}
}
return 0;
}
Conturbatio的更多相关文章
- hdu 5480 Conturbatio 线段树 单点更新,区间查询最小值
Conturbatio Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=54 ...
- HDU 5480:Conturbatio 前缀和
Conturbatio Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tota ...
- HDU 5480 Conturbatio
区间求和不更新,开个数组记录一下前缀和就可以了 #include<cstdio> #include<cstring> #include<cmath> #includ ...
- hdu 5480(维护前缀和+思路题)
Conturbatio Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
随机推荐
- linux 文件属性文件权限
权限 -rw-------. root root Mar : anaconda-ks.cfg drwxr-xr-x root root May : dir1 drwxr-xr-x root root ...
- AcWing 875. 快速幂
题目链接:https://www.acwing.com/problem/content/description/877/ 快速幂模板题,计算ab mod p 的值,a,b,p大概1e9左右,可以快速计 ...
- 【JZOJ 3910】Idiot 的间谍网络
题面: Description 作为一名高级特工,Idiot 苦心经营多年,终于在敌国建立起一张共有n 名特工的庞大间谍网络. 当然,出于保密性的要求,间谍网络中的每名特工最多只会有一名直接领导.现在 ...
- W10: Warning: Changing a readonly file 解决办法
在linux上编辑文件的时候,明明是使用的root登录的,可是这种至高无上的权限在按下i的时候被那串红色错误亵渎了W10: Warning: Changing a readonly file. 困扰两 ...
- 各类无次数限制的免费API接口,再也不怕找不到免费API了
各类无次数限制的免费API接口整理,主要是聚合数据上和API Store上的一些,还有一些其他的. 聚合数据提供30大类,160种以上基础数据API服务,国内最大的基础数据API服务,下面就罗列一些免 ...
- webdriver 的使用 java 和python 两个版本
在使用webdriver前要先做下准备,1.下载相应的支持包,可以pom.xml文件引入 2.下载版本对应的浏览器驱动(我这里用的是chromedriver.exe),很多问题都是由于浏览器驱动引起的 ...
- 图解Qt安装(Linux平台)
http://c.biancheng.net/view/3886.html Linux 发行版虽然众多,但 Qt 安装过程大同小异,本节以 CentOS 7 为例来演示 Qt 的安装. 在<Qt ...
- opencv python 图像二值化/简单阈值化/大津阈值法
pip install matplotlib 1简单的阈值化 cv2.threshold第一个参数是源图像,它应该是灰度图像. 第二个参数是用于对像素值进行分类的阈值, 第三个参数是maxVal,它表 ...
- Linux架构之Nginx 高可用
第53章 Nginx之高可用Keepalived 一.Keepalived高可用基本概述 1.1)什么是高可用 一般是指2台机器启动着完全相同的业务系统,当有一台机器down机了,另外一台服务器就能快 ...
- linux c++下遍历文件
https://blog.csdn.net/u013617144/article/details/44807333