codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1717B.md (2434B)


      1 Source: https://codeforces.com/problemset/problem/1717/B
      2 
      3 B. Madoka and Underground Competitions
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Madoka decided to participate in an underground sports programming competition. And there was exactly one task in it:
     22 
     23 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'.
     24 
     25 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.
     26 
     27 Input
     28 
     29 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.
     30 
     31 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$.
     32 
     33 It is guaranteed that the sum of $n$ over all test cases does not exceed $500$.
     34 
     35 Output
     36 
     37 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.
     38 
     39 Example
     40 
     41 Input
     42 
     43 ```
     44 3
     45 
     46 3 3 3 2
     47 
     48 2 1 1 2
     49 
     50 6 3 4 2
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 X..
     57 ..X
     58 .X.
     59 XX
     60 XX
     61 .X..X.
     62 X..X..
     63 ..X..X
     64 .X..X.
     65 X..X..
     66 ..X..X
     67 ```
     68 
     69 Note
     70 
     71 Let's analyze the first test case.
     72 
     73 The following tables can be printed as the correct answer:
     74 
     75 |  |
     76 | --- |
     77 | X.. |
     78 | ..X |
     79 | .X. |
     80 
     81 or
     82 
     83 |  |
     84 | --- |
     85 | ..X |
     86 | X.. |
     87 | .X. |
     88 
     89  It can be proved that there cannot be less than $3$ characters 'X' in the answer.
     90 
     91 Note that the following table is invalid because cell $(3, 2)$ does not contain the character 'X':
     92 
     93 |  |
     94 | --- |
     95 | X.. |
     96 | .X. |
     97 | ..X |
     98 
     99 In the second test case, the only correct table is:
    100 
    101 |  |
    102 | --- |
    103 | XX |
    104 | XX |
    105 
    106  Each subtable of size $1 \times 1$ must contain a 'X' character, so all characters in the table must be equal to 'X'.