编程介的小学生 2017-04-28 10:32 采纳率: 20.5%
浏览 802
已采纳

Bookshelf Demo

The new semester starts and Polivic's girlfriend has bought a bookshelf but since she has got so many books and things are in a mess. Of course, Polivic is always willing to help.

He wants to illustrate what the bookshelf will look like. As photoshop never touches his mind, ASCII is the solution.

Input

There are multiple tests. Each case starts with two integers W and L:

W (width of the bookshelf)

L (levels of the bookshelf)

The following L lines describe each level in the form:

Hi (height of this level) Ni (number of books in this level), followed by 2Ni integers for height and width of each book.

A case with W = 0 signals the end of input and this case shall not be processed.

Output

Print each bookshelf followed with a blank line.

Notice that:

1) The top and bottom of the bookself is of one unit height, and two unit wider than the rest levels.

2) On each level the books are arranged from the left-most in the order of input.

3) The input is always legal.

Sample Input

20 2
5 2 2 1 4 2
3 1 2 2
0

Sample Output

(Refer to the image.)

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器