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. SPI总线小结

    串行外设接口(Serial Peripheral Interface,SPI)的缩写.是一种高速的,全双工,同步的通信总线,并且在芯片的管脚上只占用四根线.Motorola首先在其MC68HCXX系列 ...

  2. 从零开始部署小型企业级虚拟桌面 -- Vmware Horizon View 6 For Linux VDI

    环境说明 注,本套环境所用机器全部是64位的. 管理服务器载体:安装win7操作系统,通过VMware Workstation安装4台虚拟机,用作vCenter,Connection Server,D ...

  3. lspci详解分析

    lspci详解分析 一.PCI简介 PCI是一种外设总线规范.我们先来看一下什么是总线:总线是一种传输信号的路径或信道.典型情况是,总线是连接于一个或多个导体的电气连线,总 线上连接的所有设备可在同一 ...

  4. python之操作excel:xlrd、xlwt、xlutiles、枚举函数enumerate()

    一.读excel: xlrd-----只能读.不能写 import xlrd book=xlrd.open_workbook(r'E:\BestTest\内容\名单.xlsx') #打开excel s ...

  5. modify django app models.py adn settings.py

    from django.db import models from django.contrib import admin # from personal import models class Us ...

  6. 微信小程序之裁剪图片成圆形

    前言 最近在开发小程序,产品经理提了一个需求,要求微信小程序换头像,用户剪裁图片必须是圆形,也在github上看了一些例子,一般剪裁图片用的都是方形,所以自己打算写一个小组件,可以把图片剪裁成圆形,主 ...

  7. css3浏览器兼容的前缀

    -moz代表firefox浏览器私有属性 -ms代表ie浏览器私有属性 -webkit代表safari.chrome私有属性

  8. vs编译应用程序不依赖运行vs环境

    控制台应用程序不依赖VS运行环境就可以运行的设置: 1,使用release模式编译 2,项目属性中,“C/C++”,“代码生成”中的运行库改为“多线程(/MT)” 3,项目属性中,“链接器”,“系统” ...

  9. PyQt5-Python3-PyCharm 配置

    File->Tools->External Tools->add 配置ui文件转换工具 Name: PyUIC Program: D:\develop\python\Mac\venv ...

  10. vue 单独页面定时器 离开页面销毁定时器

    data: { return { timer: null } }, created() { this.timer = setInterval(....); }, beforeDestroy() { i ...