QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 256 MB مجموع النقاط: 100

#11913. 晨晨、唐唐和曾曾

الإحصائيات

Chenchen、Tangtang 和 ZengZeng 正在进行一场在 $3 \times 3$ 棋盘上进行的井字棋游戏。

最初,棋盘上的所有格子都是空的。他们轮流将自己名字的首字母填入任意一个空格中(因为 Chenchen、Tangtang 和 ZengZeng 是精英,他们的名字首字母各不相同,分别为 'C'、'T' 和 'Z')。当有人在行、列或对角线上连成 3 个自己的字母时,游戏结束,该人获胜。

编写一个程序,根据给定的棋盘状态,判断游戏是否结束,如果结束,判断谁获胜。

输入格式

输入包含多组测试数据,最多 1000 组。

输入的第一行包含一个整数,表示测试数据的组数。每组数据包含三行,描述棋盘状态。每行包含 3 个字符。字符为大写字母 {'C', 'T', 'Z'} 或 '.'(表示格子为空)。数据保证最多只有一名获胜者。

输出格式

对于每组数据,如果游戏已结束,输出获胜者的名字首字母。如果游戏未结束,即使棋盘已满,也输出 “ongoing”。

样例

输入格式 1

4
CTZ
TCZ
CTZ
ZCT
CZC
TTZ
.C.
C.T
Z..
CTZ
.C.
CTZ

输出格式 1

Z
Z
ongoing
ongoing

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.