codeforces-scrape

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

2094F.md (1348B)


      1 Source: https://codeforces.com/problemset/problem/2094/F
      2 
      3 F. Trulimero Trulicina
      4 
      5 time limit per test
      6 
      7 2 seconds
      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 Trulicina gives you integers $n$, $m$, and $k$. It is guaranteed that $k\geq 2$ and $n\cdot m\equiv 0 \pmod{k}$.
     22 
     23 Output a $n$ by $m$ grid of integers such that each of the following criteria hold:
     24 
     25 * Each integer in the grid is between $1$ and $k$, inclusive.
     26 * Each integer from $1$ to $k$ appears an equal number of times.
     27 * No two cells that share an edge have the same integer.
     28 
     29 It can be shown that such a grid always exists. If there are multiple solutions, output any.
     30 
     31 Input
     32 
     33 The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.
     34 
     35 The first line of each test case contains three integers $n$, $m$, and $k$ ($2 \leq n\cdot m\leq 2\cdot 10^5, 2\leq k\leq n\cdot m, n\cdot m\equiv 0 \pmod{k})$.
     36 
     37 It is guaranteed that the sum of $n\cdot m$ over all test cases does not exceed $2\cdot 10^5$.
     38 
     39 Output
     40 
     41 For each test case, output $n$ lines, each containing $m$ integers that satisfy the criteria. If there are multiple solutions, output any.
     42 
     43 Example
     44 
     45 Input
     46 
     47 ```
     48 3
     49 
     50 2 2 2
     51 
     52 3 4 6
     53 
     54 5 5 25
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 1 2
     61 2 1
     62 1 6 1 6
     63 2 5 2 5
     64 3 4 3 4
     65 17 2 12 25 14
     66 3 1 6 19 11
     67 8 20 23 24 4
     68 9 10 5 13 21
     69 22 7 15 18 16
     70 ```