区域安全的check方法就是, 每行都有哨兵或者每列都有哨兵,然后我们用y建线段树, 维护在每个y上的哨兵的x的最值就好啦。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long using namespace std; const int N = 2e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-;
const double PI = acos(-); int n, m, k, q;
bool ans[N]; PII p[N];
struct Qus {
PII a, b;
bool operator < (const Qus& rhs) const {
return b < rhs.b;
}
int id;
} qus[N]; int a[N << ];
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
void update(int p, int val, int l, int r, int rt) {
if(l == r) {
a[rt] = max(a[rt], val);
return;
}
int mid = l + r >> ;
if(p <= mid) update(p, val, lson);
else update(p, val, rson);
a[rt] = min(a[rt << ], a[rt << | ]);
}
int query(int L, int R, int l, int r, int rt) {
if(l >= L && r <= R) return a[rt];
int mid = l + r >> ;
if(R <= mid) return query(L, R, lson);
else if(L > mid) return query(L, R, rson);
else return min(query(L, R, lson), query(L, R, rson));
} void solve() {
sort(p + , p + + k);
sort(qus + , qus + + q);
memset(a, , sizeof(a));
for(int i = , j = ; i <= q; i++) {
while(j <= k && p[j] <= qus[i].b) update(p[j].se, p[j].fi, , m, ), j++;
int mn = query(qus[i].a.se, qus[i].b.se, , m, );
if(mn >= qus[i].a.fi) ans[qus[i].id] = true;
}
} int main() {
scanf("%d%d%d%d", &n, &m, &k, &q);
for(int i = ; i <= k; i++) scanf("%d%d", &p[i].fi, &p[i].se);
for(int i = ; i <= q; i++) {
scanf("%d%d", &qus[i].a.fi, &qus[i].a.se);
scanf("%d%d", &qus[i].b.fi, &qus[i].b.se);
qus[i].id = i;
}
solve();
swap(n, m);
for(int i = ; i <= k; i++) swap(p[i].fi, p[i].se);
for(int i = ; i <= q; i++) {
swap(qus[i].a.fi, qus[i].a.se);
swap(qus[i].b.fi, qus[i].b.se);
}
solve();
for(int i = ; i <= q; i++) printf("%s\n", ans[i] ? "YES" : "NO");
return ;
} /*
*/

Codeforces 524E Rooks and Rectangles 线段树的更多相关文章

  1. VK Cup 2015 - Round 1 E. Rooks and Rectangles 线段树 定点修改,区间最小值

    E. Rooks and Rectangles Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemse ...

  2. VK Cup 2015 - Round 1 -E. Rooks and Rectangles 线段树最值+扫描线

    题意: n * m的棋盘, k个位置有"rook"(车),q次询问,问是否询问的方块内是否每一行都有一个车或者每一列都有一个车? 满足一个即可 先考虑第一种情况, 第二种类似,sw ...

  3. codeforces Good bye 2016 E 线段树维护dp区间合并

    codeforces Good bye 2016 E 线段树维护dp区间合并 题目大意:给你一个字符串,范围为‘0’~'9',定义一个ugly的串,即串中的子串不能有2016,但是一定要有2017,问 ...

  4. codeforces 22E XOR on Segment 线段树

    题目链接: http://codeforces.com/problemset/problem/242/E E. XOR on Segment time limit per test 4 seconds ...

  5. Codeforces 588E. A Simple Task (线段树+计数排序思想)

    题目链接:http://codeforces.com/contest/558/problem/E 题意:有一串字符串,有两个操作:1操作是将l到r的字符串升序排序,0操作是降序排序. 题解:建立26棵 ...

  6. Codeforces Gym 100803G Flipping Parentheses 线段树+二分

    Flipping Parentheses 题目连接: http://codeforces.com/gym/100803/attachments Description A string consist ...

  7. Codeforces GYM 100114 D. Selection 线段树维护DP

    D. Selection Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descriptio ...

  8. Codeforces 444C DZY Loves Colors(线段树)

    题目大意:Codeforces 444C DZY Loves Colors 题目大意:两种操作,1是改动区间上l到r上面德值为x,2是询问l到r区间总的改动值. 解题思路:线段树模板题. #inclu ...

  9. Codeforces 85D Sum of Medians(线段树)

    题目链接:Codeforces 85D - Sum of Medians 题目大意:N个操作,add x:向集合中加入x:del x:删除集合中的x:sum:将集合排序后,将集合中全部下标i % 5 ...

随机推荐

  1. maven打包子模块中的class文件

    通常在项目中都会使用maven进行多模块管理,默认被依赖的模块都会以jar包形式被引用.然而在J2EE项目中,当使用了Spring的自动扫描配置时,jar包形式的依赖class将不能被自动装配:< ...

  2. IDEA 实用功能Auto Import:自动优化导包(自动删除、导入包)

    JetBrains公司的intellij Idea堪称JAVA编程界的苹果,用户体验非常好 下面介绍一下IDEA的一个能显著提升写代码效率的非常好用的功能设置—— Auto Import Auto I ...

  3. charCodeAt() 和charAt()

    charAt() 方法可返回指定位置的字符. charCodeAt() 方法可返回指定位置的字符的 Unicode 编码.这个返回值是 0 - 65535 之间的整数. 方法 charCodeAt() ...

  4. Springboot使用FastJson后,接口返回中文乱码的问题解决。

    哎,天下文章一大抄,到处都是一模一样的教你怎么替换掉jackson成fastjson的,可后续中文乱码网上居然没一篇文章.翻了一会源码还是写个文章共享下吧.免得后来人又浪费时间折腾. 在springb ...

  5. 【BUG】websphere找不到类或jar包冲突

    来自:http://liuwei1578.blog.163.com/blog/static/49580364200991572642653/ Jar包冲突问题是在大型Java软件开发中经常遇到的问题, ...

  6. 设置PHPStorm 注释

    /** * Desc: xxx#if (${NAME}) * Class: ${NAME}#end#if (${NAMESPACE}) * Package: ${NAMESPACE}#end * Us ...

  7. mysql select 时间戳转标准时间写法

    select  FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S') as create_time from tabName

  8. 图文并茂的Python教程-numpy.pad

    图文并茂的Python教程-numpy.pad np.pad()常用与深度学习中的数据预处理,可以将numpy数组按指定的方法填充成指定的形状. 声明: 需要读者了解一点numpy数组的知识np.pa ...

  9. ARMV8 datasheet学习笔记4:AArch64系统级体系结构之编程模型(1)-EL/ET/ST

    1.前言 ARMV8系统级编程模型主要包括异常级别.运行状态.安全状态.同步异常.异步异常.DEBUG 本文主要对系统级编程模型做一个概要介绍 2. 异常级别 2.1 Exception level概 ...

  10. 如何读取Linux键值,输入子系统,key,dev/input/event,dev/event,C语言键盘【转】

    转自:https://blog.csdn.net/lanmanck/article/details/8423669 相信各位使用嵌入式的都希望直接读取键值,特别是芯片厂家已经提供input驱动的情况下 ...