题目:戳这里

题意:有n个矩阵,求一个点(保证存在)至少在n-1个点内。

解题思路:因为矩阵与坐标轴平行,所以我们画图可以发现如果存在点满足条件,则这些点中一定有一个是矩阵的顶点。我们可以把所有顶点的横纵坐标分别存下来排序,左下角的最大两个横纵坐标与右上角的最小两个横纵坐标相互结合,一定有一个是答案。如果不明白可以看看1029C[戳这里],算是这题的一维简化版。

附ac代码:

  1. 1 #include <cstdio>
  2. 2 #include <cstring>
  3. 3 #include <algorithm>
  4. 4 #include <string>
  5. 5 #include <vector>
  6. 6 #include <map>
  7. 7 #include <cmath>
  8. 8 #include <iostream>
  9. 9 using namespace std;
  10. 10 typedef long long ll;
  11. 11 const int maxn = 132674 + 10;
  12. 12 int n;
  13. 13 struct nod
  14. 14 {
  15. 15 int x;
  16. 16 int y;
  17. 17
  18. 18 }nua[maxn], nub[maxn];
  19. 19 int l[maxn], r[maxn], u[maxn], d[maxn];
  20. 20 void print(int lc, int dc)
  21. 21 {
  22. 22 int cnt = 0;
  23. 23 for(int i = 1; i <= n; ++i)
  24. 24 {
  25. 25 if(lc >= nua[i].x && lc <= nub[i].x && dc >= nua[i].y && dc <= nub[i].y)
  26. 26 {
  27. 27 ++cnt;
  28. 28 }
  29. 29 }
  30. 30 if(cnt >= n - 1)
  31. 31 {
  32. 32 printf("%d %d\n", lc, dc);
  33. 33 exit(0);
  34. 34 }
  35. 35 }
  36. 36 int main()
  37. 37 {
  38. 38
  39. 39 scanf("%d", &n);
  40. 40 for(int i = 1; i <= n; ++i)
  41. 41 {
  42. 42 scanf("%d %d %d %d", &l[i], &d[i], &r[i], &u[i]);
  43. 43 nua[i].x = l[i];
  44. 44 nua[i].y = d[i];
  45. 45 nub[i].x = r[i];
  46. 46 nub[i].y = u[i];
  47. 47 }
  48. 48 sort(l + 1, l + 1 + n);
  49. 49 sort(r + 1, r + 1 + n);
  50. 50 sort(d + 1, d + 1 + n);
  51. 51 sort(u + 1, u + 1 + n);
  52. 52 for(int i = 1; i <= 2; ++i)
  53. 53 {
  54. 54 for(int j = n - 1; j <= n; ++j)
  55. 55 {
  56. 56 print(l[j], u[i]);
  57. 57 print(r[i], d[j]);
  58. 58 }
  59. 59 for(int j = 1; j <= 2; ++j)
  60. 60 {
  61. 61 print(l[i], d[j]);
  62. 62 }
  63. 63 }
  64. 64 for(int i = n - 1; i <= n; ++i)
  65. 65 {
  66. 66 for(int j = n - 1; j <= n; ++j)
  67. 67 {
  68. 68 print(r[i], u[i]);
  69. 69 }
  70. 70 }
  71. 71 return 0;
  72. 72 }

codeforces 1028C Rectangles【思维】的更多相关文章

  1. CodeForces 604C 【思维水题】`

    题意: 给你01字符串的长度再给你一个串. 然后你可以在这个串中选择一个起点和一个终点使得这个连续区间内所有的位取反. 求: 经过处理后最多会得到多少次01变换. 例如:0101是4次,0001是2次 ...

  2. Minimum Integer CodeForces - 1101A (思维+公式)

    You are given qq queries in the following form: Given three integers lili, riri and didi, find minim ...

  3. Codeforces 1038D - Slime - [思维题][DP]

    题目链接:http://codeforces.com/problemset/problem/1038/D 题意: 给出 $n$ 个史莱姆,每个史莱姆有一个价值 $a[i]$,一个史莱姆可以吃掉相邻的史 ...

  4. AND Graph CodeForces - 987F(思维二进制dfs)

    题意:给出n(0≤n≤22)和m,和m个数ai,1 ≤ m ≤ 2n ,0≤ai<2n ,把ai & aj == 0 的连边,求最后有几个连通块 解析:一个一个去找肯定爆,那么就要转换一 ...

  5. CodeForces - 631C ——(思维题)

    Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...

  6. AIM Tech Round 5C. Rectangles 思维

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

  7. CF1028C Rectangles 思维

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

  8. Almost Acyclic Graph CodeForces - 915D (思维+拓扑排序判环)

    Almost Acyclic Graph CodeForces - 915D time limit per test 1 second memory limit per test 256 megaby ...

  9. Diagonal Walking v.2 CodeForces - 1036B (思维,贪心)

    Diagonal Walking v.2 CodeForces - 1036B Mikhail walks on a Cartesian plane. He starts at the point ( ...

随机推荐

  1. 环境配置-Java-02-卸载

    1.卸载程序 在windows程序与功能中卸载Java相关的两个程序 2.删除环境变量 在windows环境变量中删除JAVA_HOME.CLASSPATH 以及 PATH中的两条路径 3.查看是否卸 ...

  2. JavaScript中函数的调用!

    JavaScript中函数的调用! 1 普通函数 // 1 普通函数 function fn() { console.log(123); } // 函数名 + 一个小括号! 或者 函数名.call() ...

  3. windows10复制粘贴键突然失效无法复制粘贴的最简单办法

    报了学习班,打开了VCE的加密文档 今天复制粘贴键突然失效 在网上捣鼓了好多方法都不行最后发现看看你有没有在用加密文件,也就是网课类的文档和视频.有就把它关了关了就好了

  4. hive 时间相关的函数

    yyyy-MM-dd与yyyyMMdd000000转换的三种方法 方法一:date_format(只支持yyyy-MM-dd -> yyyyMMdd000000) select date_for ...

  5. Golang拼接字符串的5种方法及其效率_Chrispink-CSDN博客_golang 字符串拼接效率 https://blog.csdn.net/m0_37422289/article/details/103362740

    Different ways to concatenate two strings in Golang - GeeksforGeeks https://www.geeksforgeeks.org/di ...

  6. How does Go kit compare to Micro?

    Go kit - Frequently asked questions https://gokit.io/faq/ How does Go kit compare to Micro? Like Go ...

  7. 它真正的父进程在fork出子进程后就先于子进程exit退出了,所以它是一个由init继承的孤儿进程

    [Linux编程]守护进程(daemon)详解与创建_mick_seu的博客-CSDN博客_linux daemon https://blog.csdn.net/woxiaohahaa/article ...

  8. MFA

    什么是 MFA?_启用和解绑MFA_账号常见问题_账号管理-阿里云 https://help.aliyun.com/knowledge_detail/37215.html

  9. RMI笔记

    这是<java核心技术> 第11章 分布式对象的笔记. RMI基本原理 我们使用远程方法调用是希望达到这样的目的: 可以像调用本地方法一样去调用一个远程方法. 实现远程调用的方式是 为客户 ...

  10. 从URL输入到页面展现到底发生什么?

    目录 前言 一.URL 到底是啥 二.域名解析(DNS) 1.IP 地址 2.什么是域名解析 3. 浏览器如何通过域名去查询 URL 对应的 IP 呢 4. 小结 三.TCP 三次握手 1.TCP 三 ...