309675: CF1717B. Madoka and Underground Competitions

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Madoka and Underground Competitions

题意翻译

定义一个矩形是**好的**当且仅当矩形中只有字符 `.` 和 `X`,且任意 $1\times k$ 或 $k\times 1$ 的子矩形中都至少有一个 `X`。现给定 $n,k,r,c$,试构造一个 $n\times n$ 的**好的**矩形使得该矩形第 $r$ 行第 $c$ 列为 `X`,且 `X` 的数量最少。 共有 $T$ 组数据,数据保证 $k$ 整除 $n$。

题目描述

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.

输入输出格式

输入格式


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 $ .

输出格式


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'.

Input

题意翻译

定义一个矩形是**好的**当且仅当矩形中只有字符 `.` 和 `X`,且任意 $1\times k$ 或 $k\times 1$ 的子矩形中都至少有一个 `X`。现给定 $n,k,r,c$,试构造一个 $n\times n$ 的**好的**矩形使得该矩形第 $r$ 行第 $c$ 列为 `X`,且 `X` 的数量最少。 共有 $T$ 组数据,数据保证 $k$ 整除 $n$。

Output

**题目大意**:

定义一个矩形是**好的**当且仅当矩形中只有字符 `.` 和 `X`,且任意 $1\times k$ 或 $k\times 1$ 的子矩形中都至少有一个 `X`。现给定 $n,k,r,c$,试构造一个 $n\times n$ 的**好的**矩形使得该矩形第 $r$ 行第 $c$ 列为 `X`,且 `X` 的数量最少。

**输入输出数据格式**:

- **输入格式**:
- 第一行包含一个整数 $t$($1 \le t \le 100$)——测试用例的数量。
- 每个测试用例包含一行,有四个整数 $n, k, r, c$($1 \le n \le 500, 1 \le k \le n, 1 \le r, c \le n$)——表格的大小,整数 $k$ 和必须包含字符 `X` 的单元格的坐标。保证 $n$ 是 $k$ 的倍数。
- 保证所有测试用例的 $n$ 之和不超过 $500$。

- **输出格式**:
- 对于每个测试用例,输出 $n$ 行,每行包含 $n$ 个字符 `.` 和 `X`,组成所需的表格。如果有多个答案,可以输出其中任何一个。

**输入输出样例**:

- 输入样例 #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
```**题目大意**: 定义一个矩形是**好的**当且仅当矩形中只有字符 `.` 和 `X`,且任意 $1\times k$ 或 $k\times 1$ 的子矩形中都至少有一个 `X`。现给定 $n,k,r,c$,试构造一个 $n\times n$ 的**好的**矩形使得该矩形第 $r$ 行第 $c$ 列为 `X`,且 `X` 的数量最少。 **输入输出数据格式**: - **输入格式**: - 第一行包含一个整数 $t$($1 \le t \le 100$)——测试用例的数量。 - 每个测试用例包含一行,有四个整数 $n, k, r, c$($1 \le n \le 500, 1 \le k \le n, 1 \le r, c \le n$)——表格的大小,整数 $k$ 和必须包含字符 `X` 的单元格的坐标。保证 $n$ 是 $k$ 的倍数。 - 保证所有测试用例的 $n$ 之和不超过 $500$。 - **输出格式**: - 对于每个测试用例,输出 $n$ 行,每行包含 $n$ 个字符 `.` 和 `X`,组成所需的表格。如果有多个答案,可以输出其中任何一个。 **输入输出样例**: - 输入样例 #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 ```

加入题单

算法标签: