CF596C.Wilbur and Points
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (x, y) belongs to the set, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y also belong to this set.
Now Wilbur wants to number the points in the set he has, that is assign them distinct integer numbers from 1 to n. In order to make the numbering aesthetically pleasing, Wilbur imposes the condition that if some point (x, y) gets number i, then all (x',y') from the set, such that x' ≥ x and y' ≥ y must be assigned a number not less than i. For example, for a set of four points (0, 0), (0, 1), (1, 0) and (1, 1), there are two aesthetically pleasing numberings. One is 1, 2, 3, 4 and another one is 1, 3, 2, 4.
Wilbur's friend comes along and challenges Wilbur. For any point he defines it's special value as s(x, y) = y - x. Now he gives Wilbur some _w_1, _w_2,..., w__n, and asks him to find an aesthetically pleasing numbering of the points in the set, such that the point that gets number i has it's special value equal to w__i, that is s(x__i, y__i) = y__i - x__i = w__i.
Now Wilbur asks you to help him with this challenge.
威尔伯正在研究坐标平面上的一组 $ n $ 个点。所有点的坐标均为非负整数。此外,若某点 $ (x, y) $ 属于该集合,则所有满足 $ 0 \le x' \le x $ 且 $ 0 \le y' \le y $ 的点 $ (x', y') $ 也必属于该集合。
现在,威尔伯希望为该集合中的点编号,即为其分配从 $ 1 $ 到 $ n $ 的互不相同的整数编号。为了使编号具有“美学美感”,威尔伯施加如下条件:若某点 $ (x, y) $ 被赋予编号 $ i $,则集合中所有满足 $ x' \ge x $ 且 $ y' \ge y $ 的点 $ (x', y') $ 必须被赋予不小于 $ i $ 的编号。例如,对于由四个点 $ (0, 0) 、 (0, 1) 、 (1, 0) $ 和 $ (1, 1) $ 构成的集合,存在两种符合美学要求的编号方式:一种是 $ 1, 2, 3, 4 $,另一种是 $ 1, 3, 2, 4 $。
威尔伯的朋友前来挑战他。朋友为任意一点定义其特殊值为 $ s(x,,y) = y - x $。接着,他给出序列 $ w_1, w_2, \dots, w_n $,并要求威尔伯找出该集合的一种符合美学要求的编号方式,使得被赋予编号 $ i $ 的点的特殊值恰好等于 $ w_i $,即 $ s(x_i,,y_i) = y_i - x_i = w_i $。
现在,威尔伯请你帮助他应对这一挑战。
输入格式
The first line of the input consists of a single integer n (1 ≤ n ≤ 100 000) — the number of points in the set Wilbur is playing with.
Next follow n lines with points descriptions. Each line contains two integers x and y (0 ≤ x, y ≤ 100 000), that give one point in Wilbur's set. It's guaranteed that all points are distinct. Also, it is guaranteed that if some point (x, y) is present in the input, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y, are also present in the input.
The last line of the input contains n integers. The i-th of them is w__i ( - 100 000 ≤ w__i ≤ 100 000) — the required special value of the point that gets number i in any aesthetically pleasing numbering.
输入的第一行包含一个整数 $ n ( 1 \leq n \leq 100,000 $)——表示 Wilbur 所操作的点集中的点的数量。
接下来是 $ n $ 行,每行描述一个点。每行包含两个整数 $ x $ 和 $ y ( 0 \leq x, y \leq 100,000 $),表示 Wilbur 点集中的一个点。保证所有点互不相同。此外,还保证:若某个点 $ (x, y) $ 出现在输入中,则所有满足 $ 0 \leq x' \leq x $ 且 $ 0 \leq y' \leq y $ 的点 $ (x', y') $ 也均出现在输入中。
输入的最后一行包含 $ n $ 个整数。其中第 $ i $ 个整数为 $ w_i ( -100,000 \leq w_i \leq 100,000 $)——表示在任意一种美观编号中,被编号为 $ i $ 的点所需的特殊值。
输出格式
If there exists an aesthetically pleasant numbering of points in the set, such that s(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 n lines. On the i-th of these lines print the point of the set that gets number i. If there are multiple solutions, print any of them.
如果存在一种美观的点集编号方式,使得对每个点有 s(xi,yi)=yi−xi=wi,则在输出的第一行打印 "YES";否则打印 "NO"。
若解存在,则接下来输出 n 行:第 i 行输出被编号为 i 的点。若存在多个解,输出任意一个即可。
输入输出样例
输入#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 (2, 0) gets number 3, point (0, 0) gets number one, point (1, 0) gets number 2, point (1, 1) gets number 5 and point (0, 1) gets number 4. One can easily check that this numbering is aesthetically pleasing and y__i - x__i = w__i.
In the second sample, the special values of the points in the set are 0, - 1, and - 2 while the sequence that the friend gives to Wilbur is 0, 1, 2. Therefore, the answer does not exist.
在第一个样例中,点 (2,0) 被编号为 3,点 (0,0) 被编号为 1,点 (1,0) 被编号为 2,点 (1,1) 被编号为 5,点 (0,1) 被编号为 4。可以轻松验证该编号方式是美观的,且满足 yi−xi=wi。
在第二个样例中,集合中各点的特殊值为 0、−1 和 −2,而朋友给 Wilbur 的序列是 0, 1, 2。因此,答案不存在。
输入解题思路,AI测评打分。不知道怎么写?