编程介的小学生 2017-06-13 15:45 采纳率: 20.3%
浏览 685
已采纳

Milk Bottle Data

There is a box of the shape of an N*N lattice. Each grid of the lattice may contain a milk bottle or none. Mr. Smith wrote down the data of the box by making a record for each row from left to right and each column from top to bottom. In each record, '1' indicates that there is a bottle in the corresponding grid and '0' does not. Unfortunately, the order of these records is thrown into confusion, and some of these records have corrupted.
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
NO

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面