A15337 | Madoka and Underground Competitions
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Madoka decided to participate in an underground sports programming competition. And there was exactly one task in it:
A square table of size $n \times n$ , where $n$ is a multiple of $k$ , is called good if only the characters '.' and 'X' are written in it, as well as in any subtable of size $1 \times k$ or $k \times 1$ , there is at least one character 'X'. In other words, among any $k$ consecutive vertical or horizontal cells, there must be at least one containing the character 'X'.
Output any good table that has the minimum possible number of characters 'X', and also the symbol 'X' is written in the cell $(r, c)$ . Rows are numbered from $1$ to $n$ from top to bottom, columns are numbered from $1$ to $n$ from left to right.
A square table of size $n \times n$ , where $n$ is a multiple of $k$ , is called good if only the characters '.' and 'X' are written in it, as well as in any subtable of size $1 \times k$ or $k \times 1$ , there is at least one character 'X'. In other words, among any $k$ consecutive vertical or horizontal cells, there must be at least one containing the character 'X'.
Output any good table that has the minimum possible number of characters 'X', and also the symbol 'X' is written in the cell $(r, c)$ . Rows are numbered from $1$ to $n$ from top to bottom, columns are numbered from $1$ to $n$ from left to right.
输入格式
The input consists of multiple test cases. The first line contains a single integer $t$ ( $1 \le t \le 100$ ) — the number of test cases. Description of the test cases follows.
The first and the only line of each test case contains four integers $n$ , $k$ , $r$ , $c$ ( $1 \le n \le 500, 1 \le k \le n, 1 \le r, c \le n$ ) — the size of the table, the integer $k$ and the coordinates of the cell, which must contain the character 'X'. It is guaranteed that $n$ is a multiple of $k$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $500$ .
The first and the only line of each test case contains four integers $n$ , $k$ , $r$ , $c$ ( $1 \le n \le 500, 1 \le k \le n, 1 \le r, c \le n$ ) — the size of the table, the integer $k$ and the coordinates of the cell, which must contain the character 'X'. It is guaranteed that $n$ is a multiple of $k$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $500$ .
输出格式
For each test case, output $n$ lines, each consisting of $n$ characters '.' and 'X', — the desired table. If there are several answers, then you can output anyone.
输入输出样例
输入 #1
3 3 3 3 2 2 1 1 2 6 3 4 2
输出 #1
X.. ..X .X. XX XX .X..X. X..X.. ..X..X .X..X. X..X.. ..X..X
Let's analyze the first test case.
The following tables can be printed as the correct answer:
X....X.X. or ..XX...X. It can be proved that there cannot be less than $3$ characters 'X' in the answer.Note that the following table is invalid because cell $(3, 2)$ does not contain the character 'X':
X...X...XIn the second test case, the only correct table is:
XXXX Each subtable of size $1 \times 1$ must contain a 'X' character, so all characters in the table must be equal to 'X'.
The following tables can be printed as the correct answer:
X....X.X. or ..XX...X. It can be proved that there cannot be less than $3$ characters 'X' in the answer.Note that the following table is invalid because cell $(3, 2)$ does not contain the character 'X':
X...X...XIn the second test case, the only correct table is:
XXXX Each subtable of size $1 \times 1$ must contain a 'X' character, so all characters in the table must be equal to 'X'.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted