A3115 | 拉丁方格
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Yuilice最近收到了一个拉丁谜题,里面的问题是围绕着一个被称为拉丁方格的题目展开的
拉丁方格是一个由字母 $\texttt{A}$ 、 $\texttt{B}$ 和 $\texttt{C}$ 组成的 $3 \times 3$ 格,遵循着以下两个规则:
- 在每一行中,字母 $\texttt{A}$ 、 $\texttt{B}$ 和 $\texttt{C}$ 各出现一次。
- 在每一列中,字母 $\texttt{A}$ 、 $\texttt{B}$ 和 $\texttt{C}$ 各出现一次。
例如,一个可能的拉丁方格如下所示。
$$ \begin{bmatrix} \texttt{A} & \texttt{B} & \texttt{C} \\ \texttt{C} & \texttt{A} & \texttt{B} \\ \texttt{B} & \texttt{C} & \texttt{A} \\ \end{bmatrix} $$
假如给你一个拉丁方块,但是其中一个字母被替换成了问号 $\texttt{?}$ 。请你找出被替换的字母。
拉丁方格是一个由字母 $\texttt{A}$ 、 $\texttt{B}$ 和 $\texttt{C}$ 组成的 $3 \times 3$ 格,遵循着以下两个规则:
- 在每一行中,字母 $\texttt{A}$ 、 $\texttt{B}$ 和 $\texttt{C}$ 各出现一次。
- 在每一列中,字母 $\texttt{A}$ 、 $\texttt{B}$ 和 $\texttt{C}$ 各出现一次。
例如,一个可能的拉丁方格如下所示。
$$ \begin{bmatrix} \texttt{A} & \texttt{B} & \texttt{C} \\ \texttt{C} & \texttt{A} & \texttt{B} \\ \texttt{B} & \texttt{C} & \texttt{A} \\ \end{bmatrix} $$
假如给你一个拉丁方块,但是其中一个字母被替换成了问号 $\texttt{?}$ 。请你找出被替换的字母。
输入格式
测试用例包含三行,每行由三个字符组成,代表拉丁方块。每个字符都是 $\texttt{A}$ 、 $\texttt{B}$ 、 $\texttt{C}$ 或 $\texttt{?}$ 中的一个。
测试用例都是一个拉丁方块,其中一个字母正好用问号 $\texttt{?}$ 代替。
测试用例都是一个拉丁方块,其中一个字母正好用问号 $\texttt{?}$ 代替。
输出格式
对于测试用例,输出被替换的字母。
输入输出样例
输入 #1
ABC C?B BCA
输出 #1
A
输入 #2
BCA CA? ABC
输出 #2
B
输入 #3
?AB BCA ABC
输出 #3
C
【样例解释】
前三个测试用例的正确拉丁方格如下所示:
$\begin{bmatrix} \texttt{A} & \texttt{B} & \texttt{C} \\ \texttt{C} & \color{red}{\texttt{A}} & \texttt{B} \\ \texttt{B} & \texttt{C} & \texttt{A} \\ \end{bmatrix} \quad \begin{bmatrix} \texttt{B} & \texttt{C} & \texttt{A} \\ \texttt{C} & \texttt{A} & \color{red}{\texttt{B}} \\ \texttt{A} & \texttt{B} & \texttt{C} \\ \end{bmatrix} \quad \begin{bmatrix} \color{red}{\texttt{C}} & \texttt{A} & \texttt{B} \\ \texttt{B} & \texttt{C} & \texttt{A} \\ \texttt{A} & \texttt{B} & \texttt{C} \\ \end{bmatrix}$
前三个测试用例的正确拉丁方格如下所示:
$\begin{bmatrix} \texttt{A} & \texttt{B} & \texttt{C} \\ \texttt{C} & \color{red}{\texttt{A}} & \texttt{B} \\ \texttt{B} & \texttt{C} & \texttt{A} \\ \end{bmatrix} \quad \begin{bmatrix} \texttt{B} & \texttt{C} & \texttt{A} \\ \texttt{C} & \texttt{A} & \color{red}{\texttt{B}} \\ \texttt{A} & \texttt{B} & \texttt{C} \\ \end{bmatrix} \quad \begin{bmatrix} \color{red}{\texttt{C}} & \texttt{A} & \texttt{B} \\ \texttt{B} & \texttt{C} & \texttt{A} \\ \texttt{A} & \texttt{B} & \texttt{C} \\ \end{bmatrix}$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?