hdu 5480(前缀和)
题意:如果一个点,则这点的横竖皆被占领,询问矩阵是否全被占领.
思路:将被占领的x,y标记为1,用x表示1 - i的和
如果x轴的差为 x2 - x1 + 1则表示全被占领,y轴同理
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std; const int N = 1e5 + 5;
int x[N];
int y[N]; int main()
{
int t;
int n,m;
int p,q;
int x1,x2,y1,y2;
scanf("%d",&t);
while(t--)
{ scanf("%d%d%d%d",&n,&m,&p,&q);
memset(x,0,sizeof(x));
memset(y,0,sizeof(y));
for(int i = 1;i <= p;i++)
{
scanf("%d%d",&x1,&y1);
x[x1]= y[y1] = 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 i = 1;i <= q;i++)
{
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;
}
hdu 5480(前缀和)的更多相关文章
- hdu 5480(维护前缀和+思路题)
Conturbatio Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- HDU 5480:Conturbatio 前缀和
Conturbatio Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tota ...
- hdu 5480 Conturbatio 线段树 单点更新,区间查询最小值
Conturbatio Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=54 ...
- hdu 5084 前缀和预处理
http://acm.hdu.edu.cn/showproblem.php?pid=5084 给出矩阵M,求M*M矩阵的r行c列的数,每个查询跟前一个查询的结果有关. 观察该矩阵得知,令ans = M ...
- HDU 4311 前缀和
Description It has been ten years since TJU-ACM established. And in this year all the retired TJU-AC ...
- HDU 5480 Conturbatio
区间求和不更新,开个数组记录一下前缀和就可以了 #include<cstdio> #include<cstring> #include<cmath> #includ ...
- HDU - 6186 前缀和位运算
异或操作蒙蔽了我的双眼 以至于没有第一时间想到前缀和与后缀和 水题做的不够多 #include<bits/stdc++.h> #define rep(i,j,k) for(register ...
- hdu 5163(前缀和+分类讨论)
Taking Bus Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu 6025 前缀 后缀 gcd
大致题意: 去掉一个元素能使这个数列的GCD最大为多少 分析: 我们求一个数列的GCD,是先求前两个元素的GCD,然后将这个GCD值在与下一个元素进行GCD运算.由此可知进行GCD运算的顺序对最终的结 ...
随机推荐
- Vue.js学习
<!DOCTYPE html> <html> <head> <title>xxx</title> </head> <bod ...
- 限定 edittext 的 输入内容
<EditText android:id="@+id/idNumber" style="@style ...
- 【iOS】Swift GCD-下
欢迎来到本GCD教程的第二同时也是最终部分! 在第一部分中,你学到了并发,线程以及GCD的工作原理.通过使用dispatch_barrrier和dispatch_sync,你做到了让PhotoMana ...
- 微信小程序轮播图
swiper标签 <!--index.wxml--> <swiper class="swiper" indicator-dots="true" ...
- MySQL关系表查询两个表的数据
如下,有四张表:游戏类型表,游戏表,点卡和游戏关系表,点卡表 CREATE TABLE `gamesType`( `tId` INT AUTO_INCREMENT NOT NULL PRIMARY K ...
- Spring Security入门(2-2)Spring Security 的运行原理 2
- 前端开发必备之Chrome开发者工具(一)
本文介绍的 Chrome 开发者工具基于 Chrome 65版本,如果你的 Chrome 开发者工具没有下文提到的那些内容,请检查下 Chrome 的版本 简介 Chrome 开发者工具是一套内置于 ...
- 未能加载文件或程序集“ RevitAPIUI.dll”
revit二次开发中遇到的问题 RevitAPIUI.dll 只能 Native Library 中执行: 脱离了Native Library,API是跑不起来的 . 检查程序流程:登录,配置,启动r ...
- Mysql官方文档翻译系列14.18--MySql备份与恢复
原文链接: (https://dev.mysql.com/doc/refman/5.7/en/innodb-backup-recovery.html) The key to safe database ...
- Spring整合MyBaytis
1.准备jar包 A.第一种方式:配置SqlSessionFactoryBean+配置SqlSessionTemplate a.项目结构 b.applicationContext.xml 带详细注释 ...