CF1735E.House Planning
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n houses in your city arranged on an axis at points h1,h2,…,hn . You want to build a new house for yourself and consider two options where to place it: points p1 and p2 .
As you like visiting friends, you have calculated in advance the distances from both options to all existing houses. More formally, you have calculated two arrays d1 , d2 : di,j=∣pi−hj∣ , where ∣x∣ defines the absolute value of x .
After a long time of inactivity you have forgotten the locations of the houses h and the options p1 , p2 . But your diary still keeps two arrays — d1 , d2 , whose authenticity you doubt. Also, the values inside each array could be shuffled, so values at the same positions of d1 and d2 may correspond to different houses. Pay attention, that values from one array could not get to another, in other words, all values in the array d1 correspond the distances from p1 to the houses, and in the array d2 — from p2 to the houses.
Also pay attention, that the locations of the houses hi and the considered options pj could match. For example, the next locations are correct: h={1,0,3,3} , p={1,1} , that could correspond to already shuffled d1={0,2,1,2} , d2={2,2,1,0} .
Check whether there are locations of houses h and considered points p1 , p2 , for which the founded arrays of distances would be correct. If it is possible, find appropriate locations of houses and considered options.
输入格式
The first line of the input contains a single integer t ( 1≤t≤103 ) — the number of test cases. The description of test cases follows.
The first line of each test case contains one integer n ( 1≤n≤103 ) — the length of arrays d1 , d2 .
The next two lines contain n integers each: arrays d1 and d2 ( 0≤di,j≤109 ) respectively.
It is guaranteed that the sum of n over all test cases doesn't exceed 2⋅103 .
输出格式
For each test case, output a single line "NO" if there is no answer.
Otherwise output three lines. The first line must contain "YES". In the second line, print n integers h1,h2,…,hn . In the third line print two integers p1 , p2 .
It must be satisfied that 0≤hi,p1,p2≤2⋅109 . We can show that if there is an answer, then there is one satisfying these constraints.
If there are several answers, output any of them.
输入输出样例
输入#1
4 1 5 5 2 10 12 5 20 2 10 33 26 69 4 0 2 1 2 2 2 1 0
输出#1
YES 5 0 10 NO YES 0 43 33 69 YES 1 0 3 3 1 1
说明/提示
In the image below you can see the sample solutions. Planned houses are shown in bright colours: pink and purple. Existing houses are dim.
In test case 1 , the first planned house is located at point 0 , the second at point 10 . The existing house is located at point 5 and is at a distance of 5 from both planned houses.
It can be shown that there is no answer for test case 2 .
In test case 3 , the planned houses are located at points 33 and 69 .
Note that in test case 4 , both plans are located at point 1 , where one of the existing houses is located at the same time. It is a correct placement.