QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#14462. Gomoku

統計

Little C and Little Q are playing a game of Gomoku. A player is considered the winner if they have at least 5 consecutive pieces in the same row, the same column, or along a 45-degree diagonal (top-left to bottom-right, or top-right to bottom-left).

Little C and Little Q are so engrossed in the game that they haven't noticed if someone has already won. Can you write a program to help them determine who has won?

Input

The first line contains an integer $n$ ($5 \le n \le 10$), representing the size of the board as an $n \times n$ grid.

The next $n$ lines each contain $n$ characters. The $j$-th character of the $i$-th line represents the state of the cell at row $i$ and column $j$.

Specifically, each character will be one of the following three: .: There is no piece at this position. C: There is a piece belonging to Little C at this position. * Q: There is a piece belonging to Little Q at this position.

Output

Output a single line containing a string representing the result.

If no one has won yet, output No winner till now.

If Little C satisfies the winning condition but Little Q does not, output The winner is little C.

If Little Q satisfies the winning condition but Little C does not, output The winner is little Q.

If both players satisfy the winning condition, output Too late to know who the winner is.

Examples

Input 1

6
....C.
...CQ.
..CQCC
.CQQQ.
QQCCC.
Q.....

Output 1

The winner is little Q

Input 2

5
CQCQC
QCQCQ
CQCQC
QCQCQ
CQCQC

Output 2

The winner is little C

Input 3

6
CCCCCQ
....Q.
...Q..
..Q...
.Q....
CCQCCC

Output 3

Too late to know who the winner is

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.