题解:

首先这个东西因为强制在线区间查询

所以外面得套线段树了

然后考虑几条线段怎么判定

我们只需要按照右端点排序,然后查询的时候查找最右节点的前缀最大值就可以了

然后怎么合并子区间信息呢

(刚开始我很zz的觉得应该要线段树合并。。)

线段树都保证了区间一样大每个点暴力也就会算log次。。

于是就直接暴力合并就好了

复杂度$nlogn^2$

然后因为是cf题。。完全不管常数 成功跑了luogu倒数rank1

感觉前面跑那么快应该是有$nlogn$的做法

#updata:

果然是有nlogn的做法

考虑按照x-y的x从大到小排序建立主席树 ,然后维护每个点y的最小值,线段树上维护最小值的最大值就可以了

于是每次二分找到第一个$>=$它的x位置然后主席树区间查询就可以了

代码:

#include <bits/stdc++.h>
using namespace std;
#define rint register int
#define IL inline
#define rep(i,h,t) for(int i=h;i<=t;i++)
#define dep(i,t,h) for(int i=t;i>=h;i--)
#define ll long long
#define me(x) memset(x,0,sizeof(x))
#define mep(x,y) memcpy(x,y,sizeof(y))
#define mid ((h+t)>>1)
namespace IO{
char ss[<<],*A=ss,*B=ss;
IL char gc()
{
return A==B&&(B=(A=ss)+fread(ss,,<<,stdin),A==B)?EOF:*A++;
}
template<class T> void read(T &x)
{
rint f=,c; while (c=gc(),c<||c>) if (c=='-') f=-; x=(c^);
while (c=gc(),c>&&c<) x=(x<<)+(x<<)+(c^); x*=f;
}
char sr[<<],z[]; int Z,C1=-;
template<class T>void wer(T x)
{
if (x<) sr[++C1]='-',x=-x;
while (z[++Z]=x%+,x/=);
while (sr[++C1]=z[Z],--Z);
}
IL void wer1()
{
sr[++C1]=' ';
}
IL void wer2()
{
sr[++C1]='\n';
}
template<class T>IL void maxa(T &x,T y) {if (x<y) x=y;}
template<class T>IL void mina(T &x,T y) {if (x>y) x=y;}
template<class T>IL T MAX(T x,T y){return x>y?x:y;}
template<class T>IL T MIN(T x,T y){return x<y?x:y;}
};
using namespace IO;
const int N=3.1e5;
const int N1=N*;
struct re{
int a,b;
};
bool cmp(re x,re y)
{
return x.b<y.b;
}
vector<re> ve[N];
struct sgt{
vector<re> ve1[N1];
IL void updata(int x)
{
int l1=(int)(ve1[x*].size())-;
int l2=(int)(ve1[x*+].size())-;
int h1=,h2=,lst1=,lst2=;
while (h1<=l1||h2<=l2)
{
int t;
if (h1<=l1&&h2<=l2)
t=MIN(ve1[x*][h1].b,ve1[x*+][h2].b);
else if (h1<=l1) t=ve1[x*][h1].b; else t=ve1[x*+][h2].b;
while (h1<=l1&&ve1[x*][h1].b==t)
maxa(lst1,ve1[x*][h1].a),h1++;
while (h2<=l2&&ve1[x*+][h2].b==t)
maxa(lst2,ve1[x*+][h2].a),h2++;
ve1[x].push_back((re){MIN(lst1,lst2),t});
}
}
void build(int x,int h,int t)
{
if (h==t)
{
int l=(int)(ve[h].size())-;
rep(i,,l) ve1[x].push_back(ve[h][i]);
sort(ve1[x].begin(),ve1[x].end(),cmp);
int lst=;
rep(i,,l)
{
maxa(lst,ve1[x][i].a);
ve1[x][i].a=lst;
}
return;
}
build(x*,h,mid); build(x*+,mid+,t);
updata(x);
}
IL bool query(int x,int h,int t,int h1,int t1,int x1,int y)
{
if (h1<=h&&t<=t1)
{
int h=,t=(int)(ve1[x].size())-;
if (t<) return();
if (ve1[x][h].b>y) return();
while (h<t)
{
int mid2=(h+t+)/;
if (ve1[x][mid2].b<=y) h=mid2; else t=mid2-;
}
if (ve1[x][h].a>=x1) return(); else return();
}
bool tt=;
if (h1<=mid) tt&=query(x*,h,mid,h1,t1,x1,y);
if (mid<t1) tt&=query(x*+,mid+,t,h1,t1,x1,y);
return tt;
}
}S;
int main()
{
int n,m,k;
ios::sync_with_stdio(false);
cin>>n>>m>>k;
rep(i,,k)
{
int x,y,z;
cin>>x>>y>>z;
ve[z].push_back((re){x,y});
}
S.build(,,n);
rep(i,,m)
{
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
if (S.query(,,n,x1,y1,x2,y2)) cout.flush()<<"yes"<<endl;
else cout.flush()<<"no"<<endl;
}
return ;
}

Codeforces Round #524 (Div. 2) F的更多相关文章

  1. Codeforces Round #524 (Div. 2) F. Katya and Segments Sets(主席树)

    https://codeforces.com/contest/1080/problem/F 题意 有k个区间,区间的种类有n种,有m个询问(n,m<=1e5,k<=3e5),每次询问a,b ...

  2. Codeforces Round #485 (Div. 2) F. AND Graph

    Codeforces Round #485 (Div. 2) F. AND Graph 题目连接: http://codeforces.com/contest/987/problem/F Descri ...

  3. Codeforces Round #486 (Div. 3) F. Rain and Umbrellas

    Codeforces Round #486 (Div. 3) F. Rain and Umbrellas 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...

  4. Codeforces Round #501 (Div. 3) F. Bracket Substring

    题目链接 Codeforces Round #501 (Div. 3) F. Bracket Substring 题解 官方题解 http://codeforces.com/blog/entry/60 ...

  5. Codeforces Round #499 (Div. 1) F. Tree

    Codeforces Round #499 (Div. 1) F. Tree 题目链接 \(\rm CodeForces\):https://codeforces.com/contest/1010/p ...

  6. Codeforces Round #524 (Div. 2)(前三题题解)

    这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...

  7. Codeforces Round #376 (Div. 2)F. Video Cards(前缀和)

    题目链接:http://codeforces.com/contest/731/problem/F 题意:有n个数,从里面选出来一个作为第一个,然后剩下的数要满足是这个数的倍数,如果不是,只能减小为他的 ...

  8. Codeforces Round #271 (Div. 2) F. Ant colony (RMQ or 线段树)

    题目链接:http://codeforces.com/contest/474/problem/F 题意简而言之就是问你区间l到r之间有多少个数能整除区间内除了这个数的其他的数,然后区间长度减去数的个数 ...

  9. Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid

    F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

随机推荐

  1. 使用jar包格式化Docker 容器日志

    前面使用JS格式化textarea中的日志内容,但局限于JS语言性能,在日志内容较多时效率无法接受,建议日志内容大于5000行时转投本java程序,文末提供jar包下载. LogsFormat.jav ...

  2. 解决远程连接MongoDB出现错误

    前言:最近准备学习下MongoDB,安装什么的都已经弄完了,想远程连接来管理MongoDB,用的软件是robo 3t 第一次连的时候就出错误了 大概意思是连接失败,解决如下 第一步,首先检查你的服务器 ...

  3. 2019The Preliminary Contest for ICPC China Nanchang National Invitational

    The Preliminary Contest for ICPC China Nanchang National Invitational 题目一览表 考察知识点 I. Max answer 单调栈+ ...

  4. 转:centos 7 安装音频视频解码器

    (原文:https://blog.csdn.net/zhou1519/article/details/39035233/) 1.安装额外的软件源epel和nux-dextop rpm -Uvh htt ...

  5. “HtmlAgilityPack”已拥有为“System.Net.Http”定义的依赖项的解决方案

    #事故现场 在vs2013上用nuget安装 HtmlAgilityPack -Version 1.8.9时,报错如下: Install-Package : “HtmlAgilityPack”已拥有为 ...

  6. .net异步委托

    委托Delegate是一个类,定义了方法的类型, 使得可以将方法当做另一个方法的参数来进行传递,这种将方法动态地赋给参数的做法,可以避免在程序中大佬使用If-Else(Switch)语句,同时使得程序 ...

  7. Python 各种进制转换

    #coding=gbk var=input("请输入十六进制数:") b=bin(int(var,16)) print(b[2:]) 详细请参考python自带int函数.bin函 ...

  8. 携程apollo系列-客户端集成

    本文讲解如何在 Java 程序中集成 Apollo 配置, 主要涉及到一些基础用法. 对于一些高级用法, 比如如何加密/解密配置项 (可用于数据库密码配置), 如何动态切换数据源地址,如何动态切换日志 ...

  9. [物理学与PDEs]第1章习题6 无限长载流直线的磁场

    试计算电流强度为 $I$ 的无限长的直导线所产生的磁场的磁感强度. 解答: 设 $P$ 到直线的距离为 $r$, 垂足为 $P_0$, 则 ${\bf B}(P)$ 的方向为 ${\bf I}\tim ...

  10. SQL Server 常用的系统函数

    Ø  简介 本文主要列举 SQL Server 中常用的一些系统函数,帮助我们在编写 SQL 时忘了某个函数的用法方便查阅.主要分为以下几类函数,更多函数可参考官网. 1.   字符串函数 2.   ...