当前位置: 首页 > 工具软件 > Some Chess > 使用案例 >

Codeforces 493D Vasya and Chess

卫财
2023-12-01

D. Vasya and Chess
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

The input contains a single number n (2 ≤ n ≤ 109) — the size of the board.

Output

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.

Examples
input
2
output
white
1 2
input
3
output
black

思路: 博弈 先从奇数的情况开始考虑


#include <cstdio>  
#include <iostream>  
using namespace std;  
int main()  
{  
    int n;  
    cin >> n;  
    if(n&1)  
        printf("black\n");  
    else  
        printf("white\n1 2\n");  
    return 0;  
}  


 类似资料:

相关阅读

相关文章

相关问答