## CCO '06 P6 - Paint by Numbers

View as PDF

Points: 30
Time limit: 2.0s
Memory limit: 256M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
##### Canadian Computing Competition: 2006 Stage 2, Day 2, Problem 3

Years ago, there was a really bad craft/hobby called paint-by-numbers: you were given a line drawing, with numbers in each enclosed region, and the number corresponded to a particular colour. An example is shown below:

The problem you have to solve is much more linear, in a way.

You will be given an -by- grid () which you will "colour" in with either a dot (.) or a star (*).

Of course, the grid will not be specified in the usual paint-by-numbers way, since this would be too easy.

Instead, you will you have to infer which cells are blank and which contain a star. The only information you will be given are a collection of sequences of numbers, one sequence for each row and column. The sequence will indicate the size of each continuous block of stars. There must be at least one dot between two consecutive blocks of stars.

An example is shown below (which is supposed to look fish-like):

You may notice that some paint-by-number patterns are not uniquely solvable. For this problem, you may assume that any solution which satisfies the specification is correct.

#### Input Specification

Input consists of a total of lines.

The first line of the test case consists of an integer (), the number of rows. The second line consists of an integer (), the number of columns.

On the next lines, there will be sequences which describe each of the rows (from top to bottom). Each line will contain some positive integers, with a space between adjacent integers, and the sequence will end with the integer .

On the next lines describe the columns (from left to right), the same format as the rows are specified.

#### Output Specification

Output consists of lines, each line composed of characters, where each character is either a dot (.) or a star (*).

#### Sample Input 1

4
7
2 2 0
5 0
5 0
2 2 0
1 1 0
1 1 0
2 0
2 0
4 0
4 0
2 0

#### Sample Output 1

**..**.
..*****
..*****
**..**.

#### Sample Input 2

4
4
2 1 0
3 0
3 0
1 1 0
4 0
3 0
3 0
1 0

#### Sample Output 2

**.*
***.
***.