P26323 [AtCoder] Four Coloring
提高+
题目描述

Problem Description

There is a grid with $ H $ rows and $ W $ columns. Let the cell at the $ i $-th row from the top and the $ j $-th column from the left be denoted as $(i,\ j)$. The distance between cells $(i_1,\ j_1)$ and $(i_2,\ j_2)$ is defined as $ |i_1 - i_2| + |j_1 - j_2| $.

Snuke is trying to paint each cell with one of the colors: red, yellow, green, or blue. For a given positive integer $ d $, the following condition must be satisfied:

  • Any pair of cells with exactly distance $ d $ must be painted with different colors.

Find one way to paint the cells that satisfies the condition. It can be shown that a solution always exists.

Input Format

The input is given from the standard input in the following format:

$ H $ $ W $ $ d $

Output Format

Output one way to paint the cells that satisfies the condition. The output should be in the following format. Let R, Y, G, and B represent red, yellow, green, and blue, respectively, for cell $(i,\ j)$.

$ c_{11} $$ c_{12} $$ ... $$ c_{1W} $ $ : $ $ c_{H1} $$ c_{H2} $$ ... $$ c_{HW} $

Sample Input and Output

Sample Input #1

2 2 1

Sample Output #1

RY
GR

Sample Input #2

2 3 2

Sample Output #2

RYB
RGB

Notes/Hints

Constraints

  • $2 \leq H, W \leq 500$
  • $1 \leq d \leq H + W - 2$

Sample Explanation 1

The pairs of cells with exactly distance $ 1 $ are the following $ 4 $ pairs. Each pair is painted with different colors as shown on the right:
- $(1,\ 1)$ and $(1,\ 2)$ : R and Y
- $(1,\ 2)$ and $(2,\ 2)$ : Y and R
- $(2,\ 2)$ and $(2,\ 1)$ : R and G
- $(2,\ 1)$ and $(1,\ 1)$ : G and R

Sample Explanation 2

The pairs of cells with exactly distance $ 2 $ are the following $ 6 $ pairs. Each pair is painted with different colors as shown on the right:
- $(1,\ 1)$ and $(1,\ 3)$ : R and B
- $(1,\ 3)$ and $(2,\ 2)$ : B and G
- $(2,\ 2)$ and $(1,\ 1)$ : G and R
- $(2,\ 1)$ and $(2,\ 3)$ : R and B
- $(2,\ 3)$ and $(1,\ 2)$ : B and Y
- $(1,\ 2)$ and $(2,\ 1)$ : Y and R

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 2 1
样例输出
RY GR