CF596C Wilbur and Points
Description
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=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.
Input Format
The first line of the input consists of a single integer $ n $ ( $ 1
Output Format
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.
Explanation/Hint
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.