http://codeforces.com/problemset/problem/596/C

题目大意:  给你n个数对  确保如果(x,y)存在这个集合  那么  0<=x'<=x && 0<=y'<=y (x',y')也一定存在这个集合    他们规定 i的美观值=(y-x)   还会给你一个美观值序列   每一个如果都有唯一一个i与之匹配   并且 这个集合后面的所有数都不能小于前面的数  也就是说(

  1. a[s[i]].x<=a[s[i-1]].x && a[s[i]].y<=a[s[i-1]].y

分析:   我觉得应该先对a数组从小到大排序  这样避免以后在比较的时候出现错误

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. #include<ctype.h>
  5. #include<math.h>
  6. #include<queue>
  7. #include<algorithm>
  8. #include<iostream>
  9.  
  10. using namespace std;
  11. #define N 500050
  12. const double ESP = 1e-;
  13. #define INF 0x3f3f3f3f
  14. #define memset(a,b) memset(a,b,sizeof(a))
  15.  
  16. int s[N];
  17.  
  18. struct node
  19. {
  20. int x,y;
  21. }a[N];
  22. struct Node
  23. {
  24. int v,k;
  25. }b[N],c[N];
  26.  
  27. int cmp(Node p,Node q)
  28. {
  29. if(p.v!=q.v)
  30. return p.v<q.v;
  31. else
  32. return p.k<q.k;
  33. }
  34.  
  35. int cmp1(node p,node q)
  36. {
  37. if(p.x!=q.x)
  38. return p.x<q.x;
  39. else
  40. return p.y<q.y;
  41. }
  42.  
  43. int main()
  44. {
  45. int n;
  46. while(scanf("%d",&n)!=EOF)
  47. {
  48. memset(s,);
  49. memset(a,);
  50. memset(b,);
  51. memset(c,);
  52. for(int i=;i<n;i++)
  53. {
  54. scanf("%d %d",&a[i].x,&a[i].y);
  55. }
  56. sort(a,a+n,cmp1);
  57. for(int i=;i<n;i++)
  58. {
  59. c[i].v=a[i].y-a[i].x;
  60. c[i].k=i;
  61. }
  62. for(int i=;i<n;i++)
  63. {
  64. scanf("%d",&b[i].v);
  65. b[i].k=i;
  66. }
  67. sort(b,b+n,cmp);
  68. sort(c,c+n,cmp);
  69. int flag=;
  70. for(int i=;i<n;i++)
  71. {
  72. if(b[i].v!=c[i].v)
  73. {
  74. flag=;
  75. break;
  76. }
  77. else
  78. {
  79. s[b[i].k]=c[i].k;
  80. }
  81. }
  82. for(int i=;i<n;i++)
  83. {
  84. if(a[s[i]].x<=a[s[i-]].x && a[s[i]].y<=a[s[i-]].y)
  85. flag=;
  86. if(flag==)
  87. break;
  88. }
  89. if(flag==)
  90. printf("NO\n");
  91. else
  92. {
  93. printf("YES\n");
  94. for(int i=;i<n;i++)
  95. {
  96. printf("%d %d\n",a[s[i]].x,a[s[i]].y);
  97. }
  98. }
  99. }
  100. return ;
  101. }

C. Wilbur and Points---cf596C的更多相关文章

  1. Codeforces Round #331 (Div. 2) C. Wilbur and Points

    C. Wilbur and Points time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  2. Codeforces Round #331 (Div. 2)C. Wilbur and Points 贪心

    C. Wilbur and Points Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/ ...

  3. 【26.67%】【codeforces 596C】Wilbur and Points

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. CodeForces 596C Wilbur and Points

    先对n个点分类,然后按题意要求构造,构造的时候判断这个点的右上方之前是否有点,判断可以用线段树来操作. #include<cstdio> #include<cstring> # ...

  5. Codeforces Round #331 (Div. 2)

    水 A - Wilbur and Swimming Pool 自从打完北京区域赛,对矩形有种莫名的恐惧.. #include <bits/stdc++.h> using namespace ...

  6. Codeforce#331 (Div. 2) A. Wilbur and Swimming Pool(谨以此题来纪念我的愚蠢)

    C time limit per test 1 second memory limit per test 256 megabytes input standard input output stand ...

  7. Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool 水题

    A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

  8. Codeforces Round #331 (Div. 2) _A. Wilbur and Swimming Pool

    A. Wilbur and Swimming Pool time limit per test 1 second memory limit per test 256 megabytes input s ...

  9. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  10. [LeetCode] Max Points on a Line 共线点个数

    Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. ...

随机推荐

  1. mySQL ODBC 在windows 64位版上的驱动问题

    1,问题的起源 某次编辑一个asp文件,其中访问mysql数据库的连接字符串如下: "driver={mysql odbc 3.51 driver};server=localhost;uid ...

  2. python-seaborn绘图

    https://zhuanlan.zhihu.com/p/27435863 Seaborn(sns)官方文档学习笔记系列

  3. tomcat 安全配置文档

    1.配置文档中使用$CATALINA_HOME变量声明为tomcat的安装目录并明确写出了tomcat的配置文件路径,此路径为测试环境的路径,线上系统对应配置文件的路径可能不一样,在进行相关配置时,应 ...

  4. dom和bom是什么?

    DOM:文档对象模型,描述了处理网页内容的方法和接口.最根本对象是document(window.document). 由于DOM的操作对象是文档,所以DOM和浏览器没有直接关系. 部署在服务器上的文 ...

  5. python程序的编辑和运行、变量

    第一个python程序 python是解释型弱类型高级语言 常见的python解释器CPython.IPython.pypy.JPython.IronPython 方法一.python程序可以写在命令 ...

  6. 将自己的数据制作成voc格式

    VOCdevkit2007文件下只保存VOC2007,VOC2007下只保存Annotations ImageSets JPEGImages. JPEGImages存放所有的图片数据(即训练测试验证的 ...

  7. 【搜索】P1019 单词接龙

    题目描述 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母,要求出以这个字母开头的最长的“龙”(每个单词都最多在“龙”中出现两次),在两个单词相连时,其重合 ...

  8. 【软件构造】(转)Git详解、常用操作与版本图

    版本控制与Git 转自:http://www.cnblogs.com/angeldevil/p/3238470.html 版本控制 版本控制是什么已不用在说了,就是记录我们对文件.目录或工程等的修改历 ...

  9. VS打开文件,解决方案资源管理器自动定位到文件位置

    打开 工具-->选项-->项目和解决方案-->常规,勾选“在解决方案资源管理器中跟踪活动项”

  10. js hover 下拉框

    <div class="box"> <div class="a f">111111</div> <div class= ...