[Solution] House Planning Codeforces Solution
There are houses in your city arranged on an axis at points . You want to build a new house for yourself and consider two options where to place it: points and .
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 , : , where defines the absolute value of .
After a long time of inactivity you have forgotten the locations of the houses and the options , . But your diary still keeps two arrays — , , whose authenticity you doubt. Also, the values inside each array could be shuffled, so values at the same positions of and 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 correspond the distances from to the houses, and in the array — from to the houses.
Also pay attention, that the locations of the houses and the considered options could match. For example, the next locations are correct: , , that could correspond to already shuffled , .
Check whether there are locations of houses and considered points , , 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 () — the number of test cases. The description of test cases follows.
The first line of each test case contains one integer () — the length of arrays , .
The next two lines consist arrays and () respectively.
It is guaranteed that the sum of over all test cases doesn't exceed .
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 integers . In the third line print two integers , .
It must be satisfied that . 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.
No comments:
Post a Comment