We want to launch a set of satellites in the sky in orbit around earth. Two satellites may transmit data to each other in a direct way, or in indirect way (i.e. via one or more intermediate satellites), or finally may have no connection at all. We say that two satellites are neighbors if they can send data to each other in a direct way.
Given a number n of satellites and a set of n integers, find out:
The input file INPUT.TXT consists of a line containing a sequence of integers separated by spaces. The first integer, a number n <= 20, gives the number of satellites in orbit. The following n integers represent the required number of neighbors for each one of the satellites. Note that the order of these n numbers (which represent the number of neighbors for each satellite) is not important.
The first line of the output file OUTPUT.TXT contains the answer to part (a): a YES or a NO. In case of a NO in part (a), then no more output is required. In case of a YES in part (a), then a number of n lines follow containing n integers 1 or 0 separated by spaces, forming an nxn matrix. If the (i,j)-th element of this matrix is 1, then the satellites i and j are neighbors, whereas if this element is 0 then these satellites are not neighbors. The (n+2)-th line of the output file corresponds to part (c) and is a YES or a NO.
Time Limit : 20
Maximum Score : 35