#P11020. 「LAOI-6」Radiation

    ID: 10348 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>贪心洛谷原创Special JudgeO2优化构造洛谷月赛

「LAOI-6」Radiation

Description

Tom_nik and Uurist are playing a game on an n×mn\times m board. Initially the board is empty. First, Uurist places kk stones on the board, and then Tom_nik will destroy all the stones. However, for one operation, Tom_nik can only destroy stones that share a row or column.

Uurist will destroy the stones using the minimum number of operations. However, Tom_nik wants to maximize the number of operations Uurist will take by placing the stone in a proper way. You need to give him a specific placement such that Tom_nik's goal will be achieved.

Note that Uurist has to destroy all of the stones.

Input Format

This task contains multiple testcases. For each test, the first line of the input contains an integer TT, indicating the number of testcases.

Then TT lines follow, each line containing three integers n,m,kn,m,k.

Output Format

For each test case, output nn lines containing nmnm characters, indicating your answer: the character on the ii-th line and jj-th column should be "S\texttt S" (withut quotes), if you think you should place a stone on this grid; otherwise it should be ".\texttt ." (without quotes).

You should guarantee that the number of grids with S\texttt S on it is kk. If there are multiple answers, print any.

2
3 5 2
5 4 7
S....
....S
.....
S..S
...S
S.S.
...S
.S..

Hint

Subtasks are used in this problem.

Subtask 1 (2020 points): it is guaranteed that kmin(n,m)k \leq \min(n,m).
Subtask 2 (1212 points): it is guaranteed that n=2n = 2.
Subtask 3 (1818 points): it is guaranteed that T,n,m10T,n,m \leq 10.
Subtask 4 (2020 points): it is guaranteed that T10T \leq 10, n,m300n,m \leq 300.
Subtask 5 (3030 points): No special constraint.

For all tests, it is guaranteed that 1T1041 \leq T \leq 10^4, 1n,m2×1031 \leq n,m \leq 2 \times 10^3, 0knm0 \leq k \leq nm, the sum of nmnm over all test cases does not exceed 5×1065\times 10^6.