#P8924. 「GMOI R1-T1」Perfect Math Class

「GMOI R1-T1」Perfect Math Class

Problem Description

Index gives you a function as follows:

f(x)=akxk+ak1xk1++a1x1+a0f(x)=a_kx^k+a_{k-1}x^{k-1}+\cdots+a_1x^1+a_0

Draw its graph (where * means the graph passes through that point, and . means it does not) on a grid of size n×mn \times m, where the range of xx is [0,n1][0,n-1] and the range of f(x)f(x) is [0,m1][0,m-1].

Specifically, you need to output an n×mn \times m character matrix. If the function passes through an integer point (x,y)(x,y), then output * at the position that is the (x+1)(x+1)-th column from left to right and the (y+1)(y+1)-th row from bottom to top; otherwise output ..

Input Format

The first line contains three integers n,m,kn,m,k.

The second line contains k+1k+1 integers, where the ii-th integer represents ai1a_{i-1}.

Output Format

Output a total of mm lines, each containing nn characters, which is the graph of the function. Specifically, output * at the position that is the (x+1)(x+1)-th column from left to right and the (y+1)(y+1)-th row from bottom to top if and only if the function passes through (x,y)(x,y); otherwise output ..

5 5 1
0 1

....*
...*.
..*..
.*...
*....
8 8 1
0 2

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

Hint

Explanation for Sample 11:

The function is f(x)=xf(x)=x. Obviously, when x[0,4],f(x)[0,4]x\in[0,4], f(x)\in[0,4], it passes through the integer points (0,0),(1,1),(2,2),(3,3),(4,4)(0,0),(1,1),(2,2),(3,3),(4,4).

For 100%100\% of the testdata, 12ai12-12\le a_i\le 12 and n=mn=m. Each test point is equally weighted.

Test Point nn\le mm\le kk\le Special Property
11 00 -
22 55
33 11 a1=1a_1=1
44 a0+a12a_0+a_1\le 2
55 1010 -
66 22 a0=a1=0,a2na_0=a_1=0,a_2\ge n
77 100100 -
88 33
99 55
1010 77

Translated by ChatGPT 5