| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12871 | Baby Password 2 |
|
| 12968 | Gomoku |
|
Description
You are a hacker in babyland.
In babyland, people set their passwords as their favorite uppercase character.
In order to prevent a "hacker" like you from stealing passwords by peeking at the database, the passwords are shifted by some integer (possibly zero or negative) and then changed the case before being stored.
For example, if the original password is the character 'A', then after shifting by '+2' and changing the case, the actual password recorded on the database will be the second character after 'A', which is 'c'.
Original + Shift = Actual
Note that we will be dealing the alphabetic sequence as if it is a cycle, i.e., the letter before 'A' is 'Z', and the letter after 'Z' is 'A'.
Hence, if the original password is the character 'a', and the shift is '-1', the new password will be 'Z'.
You have stolen the shifted password stored on the database, denoted as C.
You also know the shift that had been applied to the original password, denoted as D.
Show the original password, followed by a newline character.
Note: Be aware of char overflow.
Input
The input will consist of the actual password and the shift
C D
(Note that C may be uppercase or lowercase character, D may be in form "-X" or "+X", where X is an integer between 0 and 25)
Output
The original password, with a trailing newline character.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Gomoku(Five in a Row) is a two-player board game. Two players(black and white) take turns placing a stone of their color on an empty intersection. The first player who forms an unbroken chain of 5 or more stones(horizontally, vertically, or diagonally) is the winner.
You have to solve q tasks. In each task, you need to output the winner(there may be no winner) for the given Gomoku board.
And in this problem:
- gridsize of the board is considered 15 x 15
- black is always the first player who starts placing the stone
- the given board must be valid
- don't consider any variation of the rule(like renju, Swap2...)
Here are three illustrations about the sample.
![]() |
![]() |
![]() |
| the board given in the first task | the board given in the second task | the board given in the third task |
The content of the sample is so many. So it's not recommended to type the sample manually to test your code.
Input
The first line contains an integer q (1 ≤ q ≤ 100) – the number of tasks you have to solve.
For each task, there are exactly 15 lines which contain exactly 15 characters each – the board you are given. 'b' and 'w' represent the stone placed by black and white respectively. And '.' represents an empty intersection.
Output
For each task output the winner(output "none" if there is no winner).
Remember to print a newline('\n') at the end of each line(task).


