题意

给出$n$个矩形,找出一个点,使得至少在$n$个矩阵内

Sol

呵呵哒,昨天cf半夜场,一道全场切的题,我没做出来。。不想找什么理由,不会做就是不会做。。

一个很显然的性质,如果存在一个点 / 矩形在$n - 1$个矩形内的话

它们的交集不会是空集。

然后我们去枚举每个点,假设他不与$(n - 1)$个矩形相交,前缀和后缀和判一下就行

/*

*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long
#define LL long long
#define rg register
#define sc(x) scanf("%d", &x);
#define pt(x) printf("%d ", x);
#define db(x) double x
#define rep(x) for(int i = 1; i <= x; i++)
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
char obuf[<<], *O = obuf;
#define OS *O++ = ' ';
using namespace std;
using namespace __gnu_pbds;
const int MAXN = 1e6 + , INF = 1e9 + , mod = 1e9 + ;
const double eps = 1e-;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N;
void print(int x) {
if(x > ) print(x / );
*O++ = x % + '';
}
struct Point {
int x1, y1, x2, y2;
Point operator + (const Point &rhs) const {
return (Point) {max(x1, rhs.x1), max(y1, rhs.y1), min(x2, rhs.x2), min(y2, rhs.y2)};
}
}P[MAXN], A[MAXN], B[MAXN];
main() {
N = read();
for(int i = ; i <= N; i++) {
P[i].x1 = read(); P[i].y1 = read();
P[i].x2 = read(); P[i].y2 = read();
}
A[] = P[]; for(int i = ; i <= N; i++) A[i] = A[i - ] + P[i];
B[N] = P[N]; for(int i = N - ; i >= ; i--) B[i] = B[i + ] + P[i];
for(int i = ; i <= N; i++) {
Point cur;
if(i == ) cur = B[];
else if(i == N) cur = A[N - ];
else cur = A[i - ] + B[i + ]; if(cur.x1 <= cur.x2 && cur.y1 <= cur.y2) {
printf("%d %d", cur.x1, cur.y1);
return ;
}
}
return ;
}
/* */

cf1028C. Rectangles(前缀和)的更多相关文章

  1. CF1028C Rectangles 思维

     Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...

  2. Codeforces Round #219 (Div. 2) D. Counting Rectangles is Fun 四维前缀和

    D. Counting Rectangles is Fun time limit per test 4 seconds memory limit per test 256 megabytes inpu ...

  3. Codeforces | CF1028C 【Rectangles】

    (这道题太简单啦...虽说我锤了一上午都没过...我能说这道题和\(CF1029C\)算是同一道题吗...) 按照时间顺序来说...\(CF1029\)在\(CF1028\)前面(而且\(CF1029 ...

  4. 【CF1028C】Rectangles(线段树)

    题意: n<=1e5,abs(x[i]),abs(y[i]<=1e9 思路:这是正解 离散后线段树强打,数据结构越学越傻 #include<cstdio> #include&l ...

  5. AIM Tech Round 5 (rated, Div. 1 + Div. 2) C. Rectangles 【矩阵交集】

    题目传传传送门:http://codeforces.com/contest/1028/problem/C C. Rectangles time limit per test 2 seconds mem ...

  6. AIM Tech Round 5C. Rectangles 思维

    C. Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  7. Codeforces 372B Counting Rectangles is Fun:dp套dp

    题目链接:http://codeforces.com/problemset/problem/372/B 题意: 给你一个n*m的01矩阵(1 <= n,m <= 40). 然后有t组询问( ...

  8. HDU-6514 Monitor(二维前缀和+差分)

    http://acm.hdu.edu.cn/showproblem.php?pid=6514 Problem Description Xiaoteng has a large area of land ...

  9. HDU1671——前缀树的一点感触

    题目http://acm.hdu.edu.cn/showproblem.php?pid=1671 题目本身不难,一棵前缀树OK,但是前两次提交都没有成功. 第一次Memory Limit Exceed ...

随机推荐

  1. LOJ114 k大异或和

    传送门 (vjudge和hdu也有但是我觉得LOJ好看!而且限制少!) 不过本题描述有误,应该是k小. 首先我们需要对线性基进行改造.需要把每一位改造成为,包含最高位的能异或出来的最小的数. 为啥呢? ...

  2. css font-family(字体样式)

    之前因为用的很少,所以没注意,最近做APP混合开发, 给字体一个样式    font-family:" 微软雅黑": 发现在有的手机上有效,但是在有的手机上是无效的, 解决方法:  ...

  3. Vue 项目中添加全局过滤器以及全局混合mixin

    可以在.vue文件中定义局部使用的过滤器 export default{ data(){ return [] }, filters:{ toUpperCase:function(value){ ret ...

  4. 利用vs自带工具分析程序性能

    测试程序写好后可以通过VS2010分析菜单里选择启用性能向导 选择CPU采样后就选择需要分析的项目 测试项目选择完成后就可以运行分析,结束分析后VS2010会提供个详细报告文档 从分析结果来看GetC ...

  5. 关于Angular6版本升级和RXJS6新特性的讲解

    从Angular5升级到Angular6, angular6相比较于angular5 总体变化不大,但是在RXJS上面却有一些变动,不得不说,虽然很讨厌break update但是RXJS6的新特性对 ...

  6. webstrom打开多个项目,webstrom常用快捷键

    1.webstrom打开多个项目 默认情况下一次只能打开一个项目,如果需要打开多个就按照下面的方法 File -> settings -> Directories -> Add Co ...

  7. 每次打开office 2013都提示配置进度,必须得等他下完然后重启,重启完了在打开,还是提示配置进度,怎么解决

    方法一: 我用下面的方法完美解决.在控制面板中1.删除旧版本2010 或者20032.删除激活程序3.重装2013激活程序done 方法二: 我把WPS卸载了就好了. 方法三: 我是按这个方法解决的, ...

  8. unity常用插件

    Unity3D常用插件,网址:http://jingyan.baidu.com/article/7f766daf4ef2844100e1d079.html ,想想自己也有小半年unity经验了,于是整 ...

  9. maven - 安装目录详解

    从 Apache Maven 官网下载 Maven 的安装包并解压之后,进入安装目录,我们会看到如下内容: 接下来我们分别解读目录的内容及其功能 bin 包含了mvn运行的脚本,在命令行输入任意一条m ...

  10. POJ-1062-昂贵的聘礼(枚举)

    链接:https://vjudge.net/problem/POJ-1062 题意: 年轻的探险家来到了一个印第安部落里.在那里他和酋长的女儿相爱了,于是便向酋长去求亲.酋长要他用10000个金币作为 ...