302553: CF493D. Vasya and Chess
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Vasya and Chess
题意翻译
有一个 $n\times n$ 的国际象棋棋盘。将白后放在 $(1,1)$ ,黑后放在 $(1,n)$ ,其余位置全都是中立的卒。 双方交替移动。白方先手。 每次移动,后(Queen)可以朝八个方向(上下左右对角线)之一移动任意格,直到碰到另外一个棋子,然后吃掉这个棋子。注意,在本题中,每次移动必须吃掉一个棋子。 当你的皇后被吃了或者你没有棋子可以吃了,就输了。 给出棋盘大小,请问哪方会赢。 - 如果黑方会赢,请输出 `black`。 - 如果白方会赢,请输出 `white`,并在下一行输出两个整数 $r,c$ ,表示白方第一步应该移动到哪里才能保证胜利。如果有多解,请输出 $r$ 最小的解,如果还有多解,请输出 $c$ 最小的解。 translated by@Planet6174题目描述
Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess. The queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is located on the same vertical, horizontal or diagonal line with queen, and the cell contains a piece of the enemy color, the queen is able to move to this square. After that the enemy's piece is removed from the board. The queen cannot move to a cell containing an enemy piece if there is some other piece between it and the queen. There is an $ n×n $ chessboard. We'll denote a cell on the intersection of the $ r $ -th row and $ c $ -th column as $ (r,c) $ . The square $ (1,1) $ contains the white queen and the square $ (1,n) $ contains the black queen. All other squares contain green pawns that don't belong to anyone. The players move in turns. The player that moves first plays for the white queen, his opponent plays for the black queen. On each move the player has to capture some piece with his queen (that is, move to a square that contains either a green pawn or the enemy queen). The player loses if either he cannot capture any piece during his move or the opponent took his queen during the previous move. Help Vasya determine who wins if both players play with an optimal strategy on the board $ n×n $ .输入输出格式
输入格式
The input contains a single number $ n $ ( $ 2<=n<=10^{9} $ ) — the size of the board.
输出格式
On the first line print the answer to problem — string "white" or string "black", depending on who wins if the both players play optimally. If the answer is "white", then you should also print two integers $ r $ and $ c $ representing the cell $ (r,c) $ , where the first player should make his first move to win. If there are multiple such cells, print the one with the minimum $ r $ . If there are still multiple squares, print the one with the minimum $ c $ .
输入输出样例
输入样例 #1
2
输出样例 #1
white
1 2
输入样例 #2
3
输出样例 #2
black