Conturbatio

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 234    Accepted Submission(s): 110

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<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的更多相关文章

  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 前缀和

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

  3. HDU 5480 Conturbatio

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

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

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

随机推荐

  1. 20191127 Spring Boot官方文档学习(9.1-9.3)

    9."使用方法"指南 9.1.Spring Boot应用程序 9.1.1.创建自己的FailureAnalyzer FailureAnalyzer被包装在FailureAnalys ...

  2. Linux运维的第三周总结

    01. 下列文件中, 包含了主机名到IP地址的映射关系的文件是()       A. /etc/HOSTNAME    B. /etc/hosts    C. /etc/resolv.conf    ...

  3. windows下安装mysql8并修改密码

    MySQL下载地址:http://dev.mysql.com/downloads/mysql/ Windows下安装MySQL 我下的是最新版的MySQL,解压后,目录如下: 1.进入dos的命令行, ...

  4. 使用批处理命令注册运行mysql数据库,无需注册mysql服务,可以在任意电脑登录使用

    使用批处理命令初始化和开启mysql服务,移植数据库之后可以直接运行访问,对于学习数据库的人来说特别的方便哦. 我们可以从mysql官网下载官方社区版本的mysql: 这里使用之前下载的8.0.15来 ...

  5. 【暑假培训1】test1

    T1: 30pts:直接暴力三层循环枚举 就就就先不写代码了qwq: 70pts: 因为X+Y+Z==0 所以我们可以考虑枚举X和Y,然后利用↑式子求出Z=-X-Y: 然后touli xcg的70pt ...

  6. .net 与directX

    微软早期出过managed assembly.但后来因为XXX的原因,没有继续出,只支持c++了..net的开发者就哭了.这篇博客解释了前世今生: https://blogs.msdn.microso ...

  7. Luogu P4040 [AHOI2014/JSOI2014]宅男计划

    题目 显然存活天数与叫外卖次数的函数是凸函数. 所以三分买外卖的次数. 然后把食品按保质期升序排序. 并且单调栈搞一下,把又贵又保质期短的丢掉. 那么随着保质期的增加,食品的价格一定上涨. 所以我们从 ...

  8. [BZOJ4444] [Luogu 4155] [LOJ 2007] [SCOI2015]国旗计划(倍增)

    [BZOJ4444] [Luogu 4155] [LOJ 2007] [SCOI2015]国旗计划(倍增) 题面 题面较长,略 分析 首先套路的断环为链.对于从l到r的环上区间,若l<=r,我们 ...

  9. ACdream 1424 Diversion( 树链剖分 )

    Diversion Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit St ...

  10. nginx运行出现 file not found 错误处理原因

    在阿里云装nginx+php+mysql nginx运行出现 file not found 错误处理原因 1,第一情况 location ~ \.php$ { # root html; fastcgi ...