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. 文件类型 | 命令ln | 软链接硬链接

    1.9文件类型 1.9.1常见文件类型 d:目录 -:普通文件 l:链接文件 b:设备 1.9.2文件后缀名 sh:shell脚本 tar.gz:压缩包 my.cnf:配置文件 test.zip:压缩 ...

  2. 第六周课程总结&实验报告

    一.实验目的 (1)掌握类的继承 (2)变量的继承和覆盖,方法的继承,重载和覆盖的实现: 二.实验的内容 (1)根据下面的要求实现圆类Circle. 1.圆类Circle的成员变量:radius表示圆 ...

  3. CentOS7 开启路由转发

    1.临时开启,(写入内存,在内存中开启) echo "1" > /proc/sys/net/ipv4/ip_forward 2.永久开启,(写入内核) 在 vim /etc/ ...

  4. JavaScript event对象clientX,offsetX,screenX异同

    event对象是JavaScript中最重要的对象之一,他代表了各种事件的状态,在各种事件的事件处理中经常用到,比如键盘活动.鼠标活动等等,其中有几个对象官方说的比较模糊,很难理解,这里有必要通俗化的 ...

  5. kafka连接器

    独立模式 bin/connect-standalone.sh config/connect-standalone.properties config/connect-file-source.prope ...

  6. Desert King(01分数规划问题)(最优斜率生成树)

    Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissions:33847   Accepted: 9208 Descr ...

  7. spring boot 枚举使用的坑3

    上一篇说到spring boot 使用jackson在枚举enum序列化和反序列化的问题, 再来说说在JPA中实体entity使用枚举的问题. 还是这个枚举: @Getter @AllArgsCons ...

  8. node搭建个人博客promise警告解除

    警告 (node:8500) UnhandledPromiseRejectionWarning: undefined (node:8500) UnhandledPromiseRejectionWarn ...

  9. ELK-全文检索技术-elasticsearch集群及sde_restful

    1       搭建ES集群 集群的说明 我们计划集群名称为:leyou-elastic,部署3个elasticsearch节点,分别是: node-01:http端口9201,TCP端口9301 n ...

  10. 九、LaTex中的浮动体

    未利用浮动体: