CF1717B.Madoka and Underground Competitions
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Madoka decided to participate in an underground sports programming competition. And there was exactly one task in it:
A square table of size n×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×k or k×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.
魔理沙决定参加一场地下体育编程竞赛。其中恰好有一道题目:
一个大小为 n×n 的方阵(其中 n 是 k 的倍数)被称为“好”的,当且仅当其中只包含字符 '.' 和 'X',并且在任意一个大小为 1×k 或 k×1 的子表中,至少有一个字符为 'X'。换言之,在任意 k 个连续的横向或纵向格子中,必须至少有一个格子包含字符 'X'。
请输出任意一个满足以下条件的“好”方阵:其中字符 'X' 的数量最少,并且位置 (r,c)(第 r 行第 c 列)上的字符必须是 'X'。行号从上到下依次为 1 至 n,列号从左到右依次为 1 至 n。
输入格式
The input consists of multiple test cases. The first line contains a single integer t (1≤t≤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≤n≤500,1≤k≤n,1≤r,c≤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.
输入包含多个测试用例。第一行包含一个整数 t(1≤t≤100),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例仅有一行,包含四个整数 n、k、r、c(1≤n≤500,1≤k≤n,1≤r,c≤n),分别表示表格的大小、整数 k,以及必须填入字符 'X' 的单元格的坐标。保证 n 是 k 的倍数。
保证所有测试用例的 n 值之和不超过 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.
对于每个测试用例,输出 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
说明/提示
Let's analyze the first test case.
The following tables can be printed as the correct answer:
X..
..X
.X.
or
..X
X..
.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.
..X
In the second test case, the only correct table is:
XX
XX
Each subtable of size 1×1 must contain a 'X' character, so all characters in the table must be equal to 'X'.
我们来分析第一个测试用例。
以下表格均可作为正确答案输出:
X..
..X
.X.
或
..X
X..
.X.
可以证明,答案中字符 'X' 的数量不可能少于 3 个。
注意,以下表格是无效的,因为单元格 (3,2) 中不包含字符 'X':
X..
.X.
..X
在第二个测试用例中,唯一正确的表格是:
XX
XX
每个大小为 1×1 的子表格都必须包含一个 'X' 字符,因此表格中的所有字符都必须为 'X'。
输入解题思路,AI测评打分。不知道怎么写?