C. Wilbur and Points---cf596C
http://codeforces.com/problemset/problem/596/C
题目大意: 给你n个数对 确保如果(x,y)存在这个集合 那么 0<=x'<=x && 0<=y'<=y (x',y')也一定存在这个集合 他们规定 i的美观值=(y-x) 还会给你一个美观值序列 每一个如果都有唯一一个i与之匹配 并且 这个集合后面的所有数都不能小于前面的数 也就是说(
- a[s[i]].x<=a[s[i-1]].x && a[s[i]].y<=a[s[i-1]].y
)
分析: 我觉得应该先对a数组从小到大排序 这样避免以后在比较的时候出现错误
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- #include<ctype.h>
- #include<math.h>
- #include<queue>
- #include<algorithm>
- #include<iostream>
- using namespace std;
- #define N 500050
- const double ESP = 1e-;
- #define INF 0x3f3f3f3f
- #define memset(a,b) memset(a,b,sizeof(a))
- int s[N];
- struct node
- {
- int x,y;
- }a[N];
- struct Node
- {
- int v,k;
- }b[N],c[N];
- int cmp(Node p,Node q)
- {
- if(p.v!=q.v)
- return p.v<q.v;
- else
- return p.k<q.k;
- }
- int cmp1(node p,node q)
- {
- if(p.x!=q.x)
- return p.x<q.x;
- else
- return p.y<q.y;
- }
- int main()
- {
- int n;
- while(scanf("%d",&n)!=EOF)
- {
- memset(s,);
- memset(a,);
- memset(b,);
- memset(c,);
- for(int i=;i<n;i++)
- {
- scanf("%d %d",&a[i].x,&a[i].y);
- }
- sort(a,a+n,cmp1);
- for(int i=;i<n;i++)
- {
- c[i].v=a[i].y-a[i].x;
- c[i].k=i;
- }
- for(int i=;i<n;i++)
- {
- scanf("%d",&b[i].v);
- b[i].k=i;
- }
- sort(b,b+n,cmp);
- sort(c,c+n,cmp);
- int flag=;
- for(int i=;i<n;i++)
- {
- if(b[i].v!=c[i].v)
- {
- flag=;
- break;
- }
- else
- {
- s[b[i].k]=c[i].k;
- }
- }
- for(int i=;i<n;i++)
- {
- if(a[s[i]].x<=a[s[i-]].x && a[s[i]].y<=a[s[i-]].y)
- flag=;
- if(flag==)
- break;
- }
- if(flag==)
- printf("NO\n");
- else
- {
- printf("YES\n");
- for(int i=;i<n;i++)
- {
- printf("%d %d\n",a[s[i]].x,a[s[i]].y);
- }
- }
- }
- return ;
- }
C. Wilbur and Points---cf596C的更多相关文章
- 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 ...
- 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/ ...
- 【26.67%】【codeforces 596C】Wilbur and Points
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces 596C Wilbur and Points
先对n个点分类,然后按题意要求构造,构造的时候判断这个点的右上方之前是否有点,判断可以用线段树来操作. #include<cstdio> #include<cstring> # ...
- Codeforces Round #331 (Div. 2)
水 A - Wilbur and Swimming Pool 自从打完北京区域赛,对矩形有种莫名的恐惧.. #include <bits/stdc++.h> using namespace ...
- 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 ...
- 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 ...
- 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 ...
- 有理数的稠密性(The rational points are dense on the number axis.)
每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.
- [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. ...
随机推荐
- mySQL ODBC 在windows 64位版上的驱动问题
1,问题的起源 某次编辑一个asp文件,其中访问mysql数据库的连接字符串如下: "driver={mysql odbc 3.51 driver};server=localhost;uid ...
- python-seaborn绘图
https://zhuanlan.zhihu.com/p/27435863 Seaborn(sns)官方文档学习笔记系列
- tomcat 安全配置文档
1.配置文档中使用$CATALINA_HOME变量声明为tomcat的安装目录并明确写出了tomcat的配置文件路径,此路径为测试环境的路径,线上系统对应配置文件的路径可能不一样,在进行相关配置时,应 ...
- dom和bom是什么?
DOM:文档对象模型,描述了处理网页内容的方法和接口.最根本对象是document(window.document). 由于DOM的操作对象是文档,所以DOM和浏览器没有直接关系. 部署在服务器上的文 ...
- python程序的编辑和运行、变量
第一个python程序 python是解释型弱类型高级语言 常见的python解释器CPython.IPython.pypy.JPython.IronPython 方法一.python程序可以写在命令 ...
- 将自己的数据制作成voc格式
VOCdevkit2007文件下只保存VOC2007,VOC2007下只保存Annotations ImageSets JPEGImages. JPEGImages存放所有的图片数据(即训练测试验证的 ...
- 【搜索】P1019 单词接龙
题目描述 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母,要求出以这个字母开头的最长的“龙”(每个单词都最多在“龙”中出现两次),在两个单词相连时,其重合 ...
- 【软件构造】(转)Git详解、常用操作与版本图
版本控制与Git 转自:http://www.cnblogs.com/angeldevil/p/3238470.html 版本控制 版本控制是什么已不用在说了,就是记录我们对文件.目录或工程等的修改历 ...
- VS打开文件,解决方案资源管理器自动定位到文件位置
打开 工具-->选项-->项目和解决方案-->常规,勾选“在解决方案资源管理器中跟踪活动项”
- js hover 下拉框
<div class="box"> <div class="a f">111111</div> <div class= ...