编程介的小学生 2019-06-12 17:56 采纳率: 20.5%
浏览 112

二进制模型的匹配和猜测的问题,怎么用C语言的程序设计思想的方式来实现的

Problem Description
Given a 01 string, you can group consecutive 1’s into blocks and write down their lengths. This is called the ‘block length sequence (BLS)’ for that string. For example, the BLS for 011100110100011 is 3, 2, 1, 2.

Similarly, given a 01 matrix, you can write down the BLS for each row and each column. Given these BLS’s, your task is to restore the 01 matrix.

Rows are read from left to right, while columns are read from top to bottom. Each test case is guaranteed to be solvable, and you’re free to output any (but only one!) solution you like.

Input
The input contains at most 10 test cases. Each test case begins with two integers n and m (1 <= n, m <= 15), the number of rows and the number of columns. The next n lines contain the BLS’s for each row, from top to bottom, and the next m lines contains the BLS’s for each column, from left to right. Each BLS ends with zero. The input ends with n = m = 0.

Output
For each case, print exactly one feasible solution you find. Each row of the matrix should occupy exactly one line. There shouldn’t be any spaces within the matrix, nor there can be any empty lines between rows, but do print an empty after each test case.

Sample Input
4 4
2 1 0
3 0
3 0
1 1 0
4 0
3 0
3 0
1 0
0 0

Sample Output
**.*
**.
*
*.
..

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值