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的更多相关文章

  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. (C#)Xamarin.ios 发布到 App Store

    项目做到尾声了,IOS要发布,程序猿力Max来了. 不过就公司开发者账号就弄了一个月多,期间因为申请过D-U-N-S客服联系要公司资料时我们中途说取消了,后来再申请不知多少次了都没再回复... 给美国 ...

  2. qt sql多重条件查询简便方法

    转载请注明出处:http://www.cnblogs.com/dachen408/p/7457312.html 程序设计过程中,经常要涉及到查询,并且有很多条件,且条件可为空,如果逐个判断,会有很多情 ...

  3. HDU 5414 CRB and String (字符串,模拟)

    题意:给两个字符串s和t,如果能插入一些字符使得s=t,则输出yes,否则输出no.插入规则:在s中选定一个字符c,可以在其后面插入一个字符k,只要k!=c即可. 思路:特殊的情况就是s和t的最长相同 ...

  4. leetcode_41. First Missing Positive_cyclic swapping

    https://leetcode.com/problems/first-missing-positive/ 给定一个长度为len的无序数组nums,找到其第一个丢失的正整数. 解法: 使用cyclic ...

  5. HashMap Hashtable TreeMap LinkedHashMap 分析

    首先对hash的了解:就是关键字,和数据建立关系的映射. hash常用算法:假设我们中的字符有相应的内部编码,当然在实际过程中,我们不可能将所有的编码当做hash值. 平方取中法,将所得的内部编码平方 ...

  6. mybatis-5 手写代理

    @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Select { public St ...

  7. 502 bad gateway nginx

    此方法可能仅对于我的问题有效 我在VMware虚拟机启动docker container nginx的,一开始启动nginx的contatiner,在浏览器是可以正常访问的,但次日重新访问时就报502 ...

  8. Java垃圾回收之回收算法

    问题:谈谈你了解的垃圾回收算法 1.标记-清除算法(Mark and Sweep) 标记:从跟集合进行扫描,对存活的对象进行标记 清除:对堆内存从头到尾进行线性遍历,回收不可达对象内存 优点:简单 缺 ...

  9. pm2 start命令中的json格式详解

    pm2 start npm -- start这条命令是pm2的万能命令,pm2 start <json>,就是这一系列命令中的最豪华命令.这个json我们可以理解为一个任务参数描述文件.通 ...

  10. python全套视频十五期(116G)

    python全套视频,第十五期,从入门到精通,基础班,就业班,面试,软件包 所属网站分类: 资源下载 > python视频教程 作者:精灵 链接:http://www.pythonheidong ...