PIB '20 P5 - 4D Matrices
View as PDFYou are given a grid  of size 
.
Using this grid, you are to generate a new grid  of size 
 as follows:
- The first element in each row 
will be assigned a value of
. The array
is unknown to you.
 - For each element 
in row
,
.
 
A third array,  will then be generated as follows:
- The 
element is the median of the
column in
.
 
It is known that the median of the array  is exactly zero. Can you determine any array 
 that makes the median of 
 zero, or state that it is impossible?
Note: For odd , the median of the array is the middle element in the sorted array. For even 
, the median is the minimum of the two middle elements in the sorted array. For example, the median of 
 is 
.
Input Specification
The first line will contain the integer  
.
The next  lines will each contain 
 integers, 
 
.
Output Specification
If it is impossible, print NO on one line.
Otherwise, print YES on the first line.
On the second line, print  space separated integers, the array 
. 
 must fit in a 32-bit integer 
, or you will receive 
Wrong Answer.
Subtasks
Subtask 1 [7%]
Subtask 2 [24%]
Subtask 3 [69%]
No additional constraints.
Sample Input for Subtask 1
4
2 1 0
3 3 0
1 6 1
1 1 1
Sample Output for Subtask 1
YES
-1 -3 -2 0
Explanation for Sample for Subtask 1
The array  that is generated with the array 
 below is:
-1  1  2  2
-3  0  3  3
-2 -1  5  6
 0  1  2  3
-----------
-2  0  2  3
The median of the array  is 
. Note that there could be multiple answers. For example, 
 is also an answer. You are only required to print any one of them.
Sample Input for Subtask 2
7
1 2 2 2 1 1
3 0 0 1 1 1
0 0 0 0 0 0
1 0 2 1 0 1
2 0 0 1 4 0
2 1 1 2 4 5
1 1 1 1 1 1
Sample Output for Subtask 2
YES
5 1 -2 -3 1 -5 -8
Sample Input for Subtask 3
3
3 -12
-6 3
6 -5
Sample Output for Subtask 3
YES
-1 5 -1
Comments