题意

给出$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. albus就是要第一个出场(线性基)

    传送门 这个题题目描述真怪异--就不能说人话吗-- 人话:给定长为n的序列A,定义f(s)为集合s内所有元素异或值,求A的所有子集的f值从小到大排列后,q在其中第一次出现的下标对10086取模的值. ...

  2. HDU2222(AC自动机入门题)

    Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others ...

  3. webpack 知识点总结

    1 webpack 的不同点: 1.1 实现代码分割 1.2 loaders 1.3 plugin system 2 webpack 打包css,需要使用css-loaders 使webpack识别c ...

  4. node.js 安装 和 配置Sublime Text的Node.js

    安装node.js 第一步:下载安装文件: https://nodejs.org/en/download/ 第二步:安装nodejs 下载完成之后,双击"node-v6.10.1-x64.m ...

  5. PHP开发api接口 -- 安全验证 生成签名

    转载博客 ————. http://blog.csdn.net/li741350149/article/details/62887524 REST模式中HTTP请求方法(GET,POST,PUT,DE ...

  6. 64位windows7下安装python,配置numpy和matplotlib库

    一.Python的安装 1.下载python2.7,下载地址:http://www.python.org/,选择系统相应版本,我选择是的是python2.7.6 . python-2.7.6rc1.a ...

  7. SQL 电子书

    http://vdisk.weibo.com/search/?type=&sortby=default&keyword=SQL+Server&filetype=&pag ...

  8. 怎么在Ubuntu下设置程序的快捷键

    参考 http://jingyan.baidu.com/article/1e5468f97f9e75484861b773.html 我的系统是 64bit Ubuntu14.04 我设置了 gedit ...

  9. AS3 滤镜相关

    <ignore_js_op> package {        import flash.display.Sprite;        import flash.filters.BlurF ...

  10. 让App飞久一点

    此文已由作者杨晓授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 本文从作者所在项目进行的耗电量测试入手,介绍了移动端App耗电量测试的一些基本概念和方法,重点介绍了iOS应用 ...