题意

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

Sol

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

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

它们的交集不会是空集。

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

  1. /*
  2.  
  3. */
  4. #include<cstdio>
  5. #include<cstring>
  6. #include<algorithm>
  7. #include<map>
  8. #include<vector>
  9. #include<set>
  10. #include<queue>
  11. #include<cmath>
  12. #include<ext/pb_ds/assoc_container.hpp>
  13. #include<ext/pb_ds/hash_policy.hpp>
  14. #define Pair pair<int, int>
  15. #define MP(x, y) make_pair(x, y)
  16. #define fi first
  17. #define se second
  18. //#define int long long
  19. #define LL long long
  20. #define rg register
  21. #define sc(x) scanf("%d", &x);
  22. #define pt(x) printf("%d ", x);
  23. #define db(x) double x
  24. #define rep(x) for(int i = 1; i <= x; i++)
  25. //#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
  26. //char buf[(1 << 22)], *p1 = buf, *p2 = buf;
  27. char obuf[<<], *O = obuf;
  28. #define OS *O++ = ' ';
  29. using namespace std;
  30. using namespace __gnu_pbds;
  31. const int MAXN = 1e6 + , INF = 1e9 + , mod = 1e9 + ;
  32. const double eps = 1e-;
  33. inline int read() {
  34. char c = getchar(); int x = , f = ;
  35. while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
  36. while(c >= '' && c <= '') x = x * + c - '', c = getchar();
  37. return x * f;
  38. }
  39. int N;
  40. void print(int x) {
  41. if(x > ) print(x / );
  42. *O++ = x % + '';
  43. }
  44. struct Point {
  45. int x1, y1, x2, y2;
  46. Point operator + (const Point &rhs) const {
  47. return (Point) {max(x1, rhs.x1), max(y1, rhs.y1), min(x2, rhs.x2), min(y2, rhs.y2)};
  48. }
  49. }P[MAXN], A[MAXN], B[MAXN];
  50. main() {
  51. N = read();
  52. for(int i = ; i <= N; i++) {
  53. P[i].x1 = read(); P[i].y1 = read();
  54. P[i].x2 = read(); P[i].y2 = read();
  55. }
  56. A[] = P[]; for(int i = ; i <= N; i++) A[i] = A[i - ] + P[i];
  57. B[N] = P[N]; for(int i = N - ; i >= ; i--) B[i] = B[i + ] + P[i];
  58. for(int i = ; i <= N; i++) {
  59. Point cur;
  60. if(i == ) cur = B[];
  61. else if(i == N) cur = A[N - ];
  62. else cur = A[i - ] + B[i + ];
  63.  
  64. if(cur.x1 <= cur.x2 && cur.y1 <= cur.y2) {
  65. printf("%d %d", cur.x1, cur.y1);
  66. return ;
  67. }
  68. }
  69. return ;
  70. }
  71. /*
  72.  
  73. */

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. node之get与post

    Get获取内容: var http=require('http'), util=require('util'),//util 提供常用函数集合 url=require('url'); http.cre ...

  2. 编译生成的h.gch文件是什么鬼?

    所谓预编译头,就是把头文件事先编译成一种二进制的中间格式,供后续的编译过程使用.GCC编译头文件后的中间文件是*.gch. 如何将头文件编译为.gch文件呢?用g++编译,格式: g++ xxx.h ...

  3. CF 757E Bash Plays with Functions——积性函数+dp+质因数分解

    题目:http://codeforces.com/contest/757/problem/E f0[n]=2^m,其中m是n的质因子个数(种类数).大概是一种质因数只能放在 d 或 n/d 两者之一. ...

  4. 修改winform安装包写日志文件权限

    1.如果程序有写入文件的功能要添加该文件 并配置该属性 改成这个即可

  5. Ubuntu12.04下安装VirtualBox

    目录: 安装虚拟机VirtualBox 虚拟机VirtualBox安装win7全过程 虚拟机共享文件夹.U盘 一.安装虚拟机VirtualBox VirtualBox下载地址:https://www. ...

  6. HDU - 2612 Find a way 双起点bfs(路径可重叠:两个队列分别跑)

    Find a way Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. CodeForces - 377A Maze BFS逆思维

    Maze Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, ...

  8. [Xcode 实际操作]九、实用进阶-(13)调用相机并获取拍摄后的图片

    目录:[Swift]Xcode实际操作 本文将演示如何调用相机并获取拍摄后的图片. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit //首 ...

  9. 多线程 GCD队列组

    //  DYFViewController.m //  623-08-队列组 // //  Created by dyf on 14-6-23. //  Copyright (c) 2014年 ___ ...

  10. [题解](树形dp/换根)小x游世界树

    2. 小x游世界树 (yggdrasi.pas/c/cpp) [问题描述] 小x得到了一个(不可靠的)小道消息,传说中的神岛阿瓦隆在格陵兰海的某处,据说那里埋藏着亚瑟王的宝藏,这引起了小x的好奇,但当 ...