欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1915B.Not Quite Latin Square
Not Quite Latin Square
A Latin square is a grid made up of the letters A, B, and C such that:
- in each row, the letters
A,B, andCeach appear once, and - in each column, the letters
A,B, andCeach appear once.
For example, one possible Latin square is shown below. $$\begin{bmatrix} \texttt{A} & \texttt{B} & \texttt{C} \ \texttt{C} & \texttt{A} & \texttt{B} \ \texttt{B} & \texttt{C} & \texttt{A} \ \end{bmatrix}$$
You are given a Latin square, but one of the letters was replaced with a question mark. Find the letter that was replaced.
Input
The first line of the input contains a single integer () — the number of testcases.
Each test case contains three lines, each consisting of three characters, representing the Latin square. Each character is one of A, B, C, or ?.
Each test case is a Latin square with exactly one of the letters replaced with a question mark ?.
Output
For each test case, output the letter that was replaced.
Note
The correct Latin squares for the three test cases are shown below:
$$$\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}$$$Samples
3
ABC
C?B
BCA
BCA
CA?
ABC
?AB
BCA
ABC
A
B
C
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |