题意:

n<=1e5,abs(x[i]),abs(y[i]<=1e9

思路:这是正解

离散后线段树强打,数据结构越学越傻

 #include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair
#define N 1100000
#define MOD 1000000007
#define eps 1e-8
#define pi acos(-1)
struct arr1
{
int x1,y1,x2,y2;
}a[N]; struct arr2
{
int x,y1,y2,z;
}c[N]; struct tree
{
int a,s,x;
}t[N<<]; int b[N],d[N],q[N],m; int read()
{
int v=,f=;
char c=getchar();
while(c<||<c) {if(c=='-') f=-; c=getchar();}
while(<=c&&c<=) v=(v<<)+v+v+c-,c=getchar();
return v*f;
} void swap(int &x,int &y)
{
int t=x;x=y;y=t;
} int hash1(int x)
{
int l=;
int r=m;
while(l<=r)
{
int mid=(l+r)>>;
if(b[mid]==x) return d[mid];
if(b[mid]<x) l=mid+;
else r=mid-;
}
} bool cmp(arr2 a,arr2 b)
{
return a.x<b.x;
} void pushdown(int p)
{
int l=p<<;
int r=l+;
if(!t[p].a) return;
t[l].s=t[l].s+t[p].a;
t[l].a=t[l].a+t[p].a;
t[r].s=t[r].s+t[p].a;
t[r].a=t[r].a+t[p].a;
t[p].a=;
} void pushup(int p)
{
if(t[p<<].s<t[p+p+].s)
{
t[p].s=t[p+p+].s;
t[p].x=t[p+p+].x;
}
else
{
t[p].s=t[p<<].s;
t[p].x=t[p<<].x;
}
} void build(int l,int r,int p)
{
if(l>r) return;
t[p].a=;
t[p].x=l;
if(l==r) return;
int mid=(l+r)>>;
build(l,mid,p<<);
build(mid+,r,p<<|);
} int query(int l,int r,int x,int y,int p)
{
if(x<=l&&r<=y) return t[p].s;
pushdown(p);
int mid=(l+r)>>;
int ret=-;
if(x<=mid) ret=query(l,mid,x,y,p<<);
if(y>mid)
{
int t=query(mid+,r,x,y,p<<|);
if(t>ret) ret=t;
}
return ret;
} void update(int l,int r,int x,int y,int v,int p)
{
if(x<=l&&r<=y)
{
t[p].s+=v;
t[p].a+=v;
return;
}
pushdown(p);
int mid=(l+r)>>;
if(x<=mid) update(l,mid,x,y,v,p<<);
if(y>mid) update(mid+,r,x,y,v,p<<|);
pushup(p);
} int main()
{
// freopen("cf1028C.in","r",stdin);
// freopen("cf1028C.out","w",stdout);
int x;
scanf("%d",&x);
int k1=x;
m=;
int n=;
for(int i=;i<=x;i++)
{
scanf("%d%d%d%d",&a[i].x1,&a[i].y1,&a[i].x2,&a[i].y2);
b[++m]=a[i].x1;
b[++m]=a[i].y1;
b[++m]=a[i].x2;
b[++m]=a[i].y2;
}
sort(b+,b+m+);
d[]=;
for(int i=;i<=m;i++)
if(b[i]==b[i-]) d[i]=d[i-];
else d[i]=d[i-]+;
q[]=b[];
int len=;
for(int i=;i<=m;i++)
if(b[i]!=b[i-]) q[++len]=b[i]; for(int i=;i<=x;i++)
{
c[++n].x=hash1(a[i].x1);
c[n].y1=hash1(a[i].y1);
c[n].y2=hash1(a[i].y2);
c[n].z=;
c[++n].x=hash1(a[i].x2)+;
c[n].y1=hash1(a[i].y1);
c[n].y2=hash1(a[i].y2);
c[n].z=-;
}
sort(c+,c+n+,cmp);
int line=;
int row=;
for(int i=;i<=n;i++)
{
line=max(line,c[i].x);
row=max(row,c[i].y2);
}
build(,row,); int j=;
for(int i=;i<=line;i++)
{
while(j<=n&&c[j].x==i)
{
update(,row,c[j].y1,c[j].y2,c[j].z,);
// printf("%d %d %d\n",c[j].y1,c[j].y2,c[j].z);
j++;
}
int k=query(,row,,row,);
//printf("%d %d\n",i,k);
if(k>=k1-)
{
// int p=find(1,row,1,row,1);
int p=t[].x;
// printf("%d %d\n",i,p);
int x=q[i];
int y=q[p];
printf("%d %d\n",x,y);
return ;
}
}
return ;
}

【CF1028C】Rectangles(线段树)的更多相关文章

  1. Codeforces 524E Rooks and Rectangles 线段树

    区域安全的check方法就是, 每行都有哨兵或者每列都有哨兵,然后我们用y建线段树, 维护在每个y上的哨兵的x的最值就好啦. #include<bits/stdc++.h> #define ...

  2. [CF983D]Arkady and Rectangles[线段树+可删堆/set]

    题意 你有一个无限大的绘图板,开始颜色是\(0\) , 你将进行\(n\) 次绘图,第\(i\) 次绘图会将左下角为 \((x_1, y_1)\),右上角为\((x_2, y_2)\) 的矩形涂成颜色 ...

  3. 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 ...

  4. hdu2461 Rectangles 线段树--扫描线

    You are developing a software for painting rectangles on the screen. The software supports drawing s ...

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

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

  6. 【做题】CSA72G - MST and Rectangles——Borůvka&线段树

    原文链接 https://www.cnblogs.com/cly-none/p/CSA72G.html 题意:有一个\(n \times n\)的矩阵\(A\),\(m\)次操作,每次在\(A\)上三 ...

  7. 线段树+扫描线 NAIPC 2019 Intersecting Rectangles

    你看看你有多菜,一点线段树的小小的运用,就不会写了: 题意:如果矩阵有交集,输出1,否则输出0(不包含内嵌): 思路:本题求交集,还得不包括内嵌的情况: 做过一道是求面积的题.跟这道类似,但在这里定义 ...

  8. POJ1151Atlantis 矩形面积并[线段树 离散化 扫描线]

    Atlantis Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21734   Accepted: 8179 Descrip ...

  9. 线段树---Atlantis

    题目网址:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=110064#problem/A Description There are se ...

随机推荐

  1. VMware9虚拟机安装MAC OS X Mountain Lion 10.8.2详细图文教程

    VMware虚拟机安装Mac OS X Mountain Lion 10.8.2所需文件:1.Vmware 9.01版下载:点击进入2.Vmware 9.01版汉化文件:点击进入3.VMware Wo ...

  2. PCA检测人脸的简单示例_matlab实现

    PCA检测人脸的简单示例,matlab R2009b上实现训练:训练用的20副人脸: %训练%Lx=X'*Xclear;clc;train_path='..\Data\TrainingSet\';ph ...

  3. kali添加更新源

    /etc/apt/sources.list 具体方法参考: http://blog.csdn.net/gmnet/article/details/14471835 http://blog.sina.c ...

  4. 2018 Python开发者大调查:Python和JavaScript最配?

    在2018年秋季,Python软件基金会与JetBrains发起了年度Python开发者调查. 报告的目的是寻找Python领域的新趋势,帮助开发者深入了解2018年Python开发者的现状. 该报告 ...

  5. 图上两点之间的第k最短路径的长度 ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven

    131072K   One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. Howe ...

  6. STM8 EEPROM心得

    对于STM8来说,其内部的EEPROM确实是个不错的东西,而且STM8S103/105价格已经非常便宜了,当然也可以用STM8S003/005代替,而且价格更便宜,大概在,1.2/2.0元左右,比10 ...

  7. Flask-用户角色及权限

    app/models.py class Role(db.Model): __tablename__ = 'roles' id = db.Column(db.Integer, primary_key=T ...

  8. HDU 3727 Jewel 主席树

    题意: 一开始有一个空序列,然后有下面四种操作: Insert x在序列尾部加入一个值为\(x\)的元素,而且保证序列中每个元素都互不相同. Query_1 s t k查询区间\([s,t]\)中第\ ...

  9. SPOJ QTREE6 Query on a tree VI 树链剖分

    题意: 给出一棵含有\(n(1 \leq n \leq 10^5)\)个节点的树,每个顶点只有两种颜色:黑色和白色. 一开始所有的点都是黑色,下面有两种共\(m(1 \leq n \leq 10^5) ...

  10. HDU 5236 Article 期望

    题意: 你现在要打\(n\)个字符,但是程序随时可能会崩溃. 你可以在恰当的时机按下 \(Ctrl-S\)键,崩溃后,会从最后一次保存的情况继续开始打字. 具体是这样的: 在每个第\(i-0.1s(i ...