CF596C.Wilbur and Points

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The first line of the input consists of a single integer nn ( 1<=n<=1000001<=n<=100000 ) — the number of points in the set Wilbur is playing with.

Next follow nn lines with points descriptions. Each line contains two integers xx and yy ( 0<=x,y<=1000000<=x,y<=100000 ), that give one point in Wilbur's set. It's guaranteed that all points are distinct. Also, it is guaranteed that if some point ( xx , yy ) is present in the input, then all points ( xx' , yy' ), such that 0<=x<=x0<=x'<=x and 0<=y<=y0<=y'<=y , are also present in the input.

The last line of the input contains nn integers. The ii -th of them is wiw_{i} ( 100000<=wi<=100000-100000<=w_{i}<=100000 ) — the required special value of the point that gets number ii in any aesthetically pleasing numbering.

输入格式

If there exists an aesthetically pleasant numbering of points in the set, such that s(xi,yi)=yixi=wis(x_{i},y_{i})=y_{i}-x_{i}=w_{i} , then print "YES" on the first line of the output. Otherwise, print "NO".

If a solution exists, proceed output with nn lines. On the ii -th of these lines print the point of the set that gets number ii . If there are multiple solutions, print any of them.

输出格式

In the first sample, point ( 22 , 00 ) gets number 33 , point ( 00 , 00 ) gets number one, point ( 11 , 00 ) gets number 22 , point ( 11 , 11 ) gets number 55 and point ( 00 , 11 ) gets number 44 . One can easily check that this numbering is aesthetically pleasing and yixi=wiy_{i}-x_{i}=w_{i} .

In the second sample, the special values of the points in the set are 00 , 1-1 , and 2-2 while the sequence that the friend gives to Wilbur is 00 , 11 , 22 . Therefore, the answer does not exist.

输入输出样例

  • 输入#1

    5
    2 0
    0 0
    1 0
    1 1
    0 1
    0 -1 -2 1 0
    

    输出#1

    YES
    0 0
    1 0
    2 0
    0 1
    1 1
    
  • 输入#2

    3
    1 0
    0 0
    2 0
    0 1 2
    

    输出#2

    NO
    

说明/提示

In the first sample, point ( 22 , 00 ) gets number 33 , point ( 00 , 00 ) gets number one, point ( 11 , 00 ) gets number 22 , point ( 11 , 11 ) gets number 55 and point ( 00 , 11 ) gets number 44 . One can easily check that this numbering is aesthetically pleasing and yixi=wiy_{i}-x_{i}=w_{i} .

In the second sample, the special values of the points in the set are 00 , 1-1 , and 2-2 while the sequence that the friend gives to Wilbur is 00 , 11 , 22 . Therefore, the answer does not exist.

首页