cf1028C. Rectangles(前缀和)
题意
给出$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(前缀和)的更多相关文章
- CF1028C Rectangles 思维
Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- 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 ...
- Codeforces | CF1028C 【Rectangles】
(这道题太简单啦...虽说我锤了一上午都没过...我能说这道题和\(CF1029C\)算是同一道题吗...) 按照时间顺序来说...\(CF1029\)在\(CF1028\)前面(而且\(CF1029 ...
- 【CF1028C】Rectangles(线段树)
题意: n<=1e5,abs(x[i]),abs(y[i]<=1e9 思路:这是正解 离散后线段树强打,数据结构越学越傻 #include<cstdio> #include&l ...
- 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 ...
- AIM Tech Round 5C. Rectangles 思维
C. Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces 372B Counting Rectangles is Fun:dp套dp
题目链接:http://codeforces.com/problemset/problem/372/B 题意: 给你一个n*m的01矩阵(1 <= n,m <= 40). 然后有t组询问( ...
- HDU-6514 Monitor(二维前缀和+差分)
http://acm.hdu.edu.cn/showproblem.php?pid=6514 Problem Description Xiaoteng has a large area of land ...
- HDU1671——前缀树的一点感触
题目http://acm.hdu.edu.cn/showproblem.php?pid=1671 题目本身不难,一棵前缀树OK,但是前两次提交都没有成功. 第一次Memory Limit Exceed ...
随机推荐
- node之get与post
Get获取内容: var http=require('http'), util=require('util'),//util 提供常用函数集合 url=require('url'); http.cre ...
- 编译生成的h.gch文件是什么鬼?
所谓预编译头,就是把头文件事先编译成一种二进制的中间格式,供后续的编译过程使用.GCC编译头文件后的中间文件是*.gch. 如何将头文件编译为.gch文件呢?用g++编译,格式: g++ xxx.h ...
- CF 757E Bash Plays with Functions——积性函数+dp+质因数分解
题目:http://codeforces.com/contest/757/problem/E f0[n]=2^m,其中m是n的质因子个数(种类数).大概是一种质因数只能放在 d 或 n/d 两者之一. ...
- 修改winform安装包写日志文件权限
1.如果程序有写入文件的功能要添加该文件 并配置该属性 改成这个即可
- Ubuntu12.04下安装VirtualBox
目录: 安装虚拟机VirtualBox 虚拟机VirtualBox安装win7全过程 虚拟机共享文件夹.U盘 一.安装虚拟机VirtualBox VirtualBox下载地址:https://www. ...
- HDU - 2612 Find a way 双起点bfs(路径可重叠:两个队列分别跑)
Find a way Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- CodeForces - 377A Maze BFS逆思维
Maze Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, ...
- [Xcode 实际操作]九、实用进阶-(13)调用相机并获取拍摄后的图片
目录:[Swift]Xcode实际操作 本文将演示如何调用相机并获取拍摄后的图片. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit //首 ...
- 多线程 GCD队列组
// DYFViewController.m // 623-08-队列组 // // Created by dyf on 14-6-23. // Copyright (c) 2014年 ___ ...
- [题解](树形dp/换根)小x游世界树
2. 小x游世界树 (yggdrasi.pas/c/cpp) [问题描述] 小x得到了一个(不可靠的)小道消息,传说中的神岛阿瓦隆在格陵兰海的某处,据说那里埋藏着亚瑟王的宝藏,这引起了小x的好奇,但当 ...