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. Entity Framework + MySQL 使用笔记

    添加: using (var edm = new NorthwindEntities()) { Customers c = ", Region = "天府广场", Con ...

  2. ubuntu服务器切换语言

    如果在安装Ubuntu Server时选择了中文,在系统安装完毕后,默认是中文,在操作时经常会显示乱码,如果需要设置回英文,则修改/etc/default/locale,将 LANG="cn ...

  3. Mysql数据库表的迁移和表的复制

    同一台服务器上的,数据库之间的表的迁移: create table db.tablename as select * from db2.tablename; 此sql使用于mysql,从一台服务器上的 ...

  4. CSS 功能简介

    CSS的功能主要包括节点管理(Node Management,以下简称NM)和组管理(Group Management,以下简称GM)两部分,都是由守护进程ocssd.bin 来实现的,这是个多线程的 ...

  5. JDO

    JDO 编辑 本词条缺少名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧! JDO(Java Data Object )是Java对象持久化的新的规范,也是一个用于存取某种数据仓库中的对象 ...

  6. vscode 快捷键 ctrl+shift+F 冲突了 解决办法

    vscode 快捷键 ctrl+shift+F 冲突了 解决办法 1.修复 搜狗输入法 ctrl+shift+F 中文 繁体简体的快捷键冲突 2.修复 微软输入法  ctrl+shift+F 冲突 ( ...

  7. 前端基础入门第一阶段-Web前端开发基础环境配置

    Web前端和全栈的定义: A.什么是传统传统web前端:需要把设计师的设计稿,切完图,写标签和样式,实现JS的效果,简而言之即只需要掌握HTML的页面结构,CSS的页面样式,javaScript页面的 ...

  8. linux部署全流程(未完)

    一.环境搭建 1.jdk 2.tomcat 3.nginx 4.redis 推荐工具:winSCP(用来传输文件).SecureCRT(用来执行命令) 1.jdk 下载地址:https://www.o ...

  9. input_shape { dim: 1 dim: 3 dim: 224 dim: 224 }

    http://blog.csdn.net/u010417185/article/details/52619593

  10. Echarts 异步数据加载遇到的问题

    看了Echarts官网异步加载数据的Demo var myChart = echarts.init(document.getElementById('main')); // 显示标题,图例和空的坐标轴 ...