Milk Bottle Data
Time Limit: 1 Second Memory Limit: 32768 KB
Special Judge
Now it's up to you to provide a program to recover these data: i.e. to give the original arrangement of the box and give real values for those corrupted data.
Input
First number is N, size of lattice. Records folows, where '2' denotes that the corresponding character has been corrupted. Each line in the file represents a record. You should output the original arrangement of the box, and show the record number for each column on the top of the lattice, and show the record number for each row to the left of the lattice. After the last lattice is '0'.
Output
You are required to give only one possible result if there are many, and you should give an indication if there is no possibility of original arrangement. Do not worry about allignment of output. Our special judge would take care of that.
Sample Input
5 01210 21120 21001 12110 12101 12101 00011 22222 11001 10010 2 00 11 11 01 0
Sample Output
9 8 6 2 7 4 1 0 1 1 0 10 1 0 0 1 0 1 0 1 1 1 0 3 0 1 0 0 1 5 1 1 1 0 1 NOSubmit
Source: Asia 1996, Shanghai (Mainland China)