区域安全的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. CRLF攻击的一篇科普:新浪某站CRLF Injection导致的安全问题(转)

    转:https://www.leavesongs.com/PENETRATION/Sina-CRLF-Injection.html 新浪某站CRLF Injection导致的安全问题 PHITHON ...

  2. 跨越VLAN

    跨越VLAN VLAN(Virtual Local Area Network),是基于以太网交互技术构建的虚拟网络,既可以将同一物理网络划分为多个VLAN,也可以跨越物理网络障碍,将不同于子网中的用户 ...

  3. Nginx 配置文件解析

    nginx 整理 nginx 配置主要是分为4个部分 1.main 全局设置2.server 主机设置 -- 指定主机与端口3.upstream 负载均衡服务器设置 -- 反向代理设置:4.locat ...

  4. pyqt5-多线程QThread类

    要实现多线程,我们要先继承QThread类并重新实现其中的run()函数,也就是说把耗时的操作放入run()函数中 import sys from PyQt5.QtCore import Qt, QT ...

  5. Ubuntu16.04安装搜狗拼音输入法(中文输入法)

    虽然网上有很多教程,但是我觉得我的很适合那些真正的小白... 1.下载文件 由于我要给多台电脑安装搜狗输入法,所以用的是文件夹安装,不是命令行安装. 打开官网http://pinyin.sogou.c ...

  6. 以前的 Delphi版本

                    Delphi 1 Delphi 2 Delphi 3 Delphi 4 Delphi 5 Delphi 6 Delphi 7 Delphi 8 Delphi 2005

  7. weblogic基本目录介绍,位数查看,启动与发布项目,修改JVM参数,设置项目为默认项目

    这里的基本目录%base%表示安装目录,如我的目录为:E:/weblogic就是%base% 1.weblogic目录介绍 weblogic主要的目录介绍: 1.日志目录: 每个domain(域)都有 ...

  8. Python模块学习 - fnmatch & glob

    介绍 fnmatch 和 glob 模块都是用来做字符串匹配文件名的标准库. fnmatch模块 大部分情况下使用字符串匹配查找特定的文件就能满足需求,如果需要更加灵活的字符串匹配,就没有办法了,这里 ...

  9. canny 算子python实现

    1. Canny介绍 Canny算子与Marr(LoG)边缘检测方法类似,也属于是先平滑后求导数的方法.John Canny研究了最优边缘检测方法所需的特性,给出了评价边缘检测性能优劣的三个指标: 1 ...

  10. MR运动静止用户区分

    1.客户端打开菜单[MR]-[MR室内室外判定设置] 设置主小区是室外站且主小区信号比较强时RSRP门限 2.设置"上报数据用户临小区切换次数门限设置"值为15 mysql中t_m ...