四种染色AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)There is an $N \times N$ grid $X$. Let $(i,j)$ denote the cell at the $i$-th row from the top and the $j$-th column from the left. We call two cells that share an edge adjacent.
有一个 $N \times N$ 的网格 $X$。令 $(i,j)$ 表示从上往下第 $i$ 行、从左往右第 $j$ 列的单元格。共享一条边的两个单元格称为相邻。AI (CI翻译)
Cell $(i,j)$ is painted with color $X_{i,j}$. The color is one of $1,2,3,4$, and adjacent cells are painted with different colors.
单元格 $(i,j)$ 被染成颜色 $X_{i,j}$。颜色为 $1,2,3,4$ 中的一种,并且 相邻单元格的颜色不同。AI (CI翻译)
You will prepare an $N \times N$ grid $Y$ and paint each cell. Let $Y_{i,j}$ denote the color painted on cell $(i,j)$ of $Y$.
现在请准备一个 $N \times N$ 的网格 $Y$,并为每个单元格染色。令 $Y_{i,j}$ 表示 $Y$ 中单元格 $(i,j)$ 所染的颜色。AI (CI翻译)
Find one way of painting that satisfies the following conditions.
请找出一种满足以下条件的染色方案。AI (CI翻译)
- The color of each cell of
$Y$is one of$1,2,3,4$. Adjacent cells may have the same color. - For any two adjacent cells
$(i_1,j_1)$and$(i_2,j_2)$, the following holds.
$Y$的每个单元格的颜色均为$1,2,3,4$中的一种。相邻单元格可以具有相同的颜色。- 对于任意两个相邻单元格
$(i_1,j_1)$和$(i_2,j_2)$,下式成立。
It can be proved that a way of painting satisfying the conditions always exists.
可以证明,满足条件的染色方案总是存在。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$2 \le N \le 500$$1 \le X_{i,j} \le 4$- Adjacent cells of
$X$are painted with different colors. - All input values are integers.
$2 \le N \le 500$$1 \le X_{i,j} \le 4$$X$中的相邻单元格被染成不同的颜色。- 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
N
X_{1,1} X_{1,2} \ldots X_{1,N}
X_{2,1} X_{2,2} \ldots X_{2,N}
\vdots
X_{N,1} X_{N,2} \ldots X_{N,N}
N
X_{1,1} X_{1,2} \ldots X_{1,N}
X_{2,1} X_{2,2} \ldots X_{2,N}
\vdots
X_{N,1} X_{N,2} \ldots X_{N,N}AI (CI翻译)
Output
输出格式
AI (CI翻译)Output a $Y$ satisfying the conditions in the following format:
按以下格式输出满足条件的 $Y$:AI (CI翻译)
Y_{1,1} Y_{1,2} \ldots Y_{1,N}
Y_{2,1} Y_{2,2} \ldots Y_{2,N}
\vdots
Y_{N,1} Y_{N,2} \ldots Y_{N,N}
Y_{1,1} Y_{1,2} \ldots Y_{1,N}
Y_{2,1} Y_{2,2} \ldots Y_{2,N}
\vdots
Y_{N,1} Y_{N,2} \ldots Y_{N,N}AI (CI翻译)
样例
3
1 2 3
2 1 4
1 3 2
4 1 4
1 3 2
4 4 2
2
1 4
4 1
1 1
1 1
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。