Codeforces Round #281 (Div. 2) D. Vasya and Chess 镜面对称 博弈论
2 seconds
256 megabytes
standard input
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.
The input contains a single number n (2 ≤ n ≤ 109) — 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.
2
white
1 2
3
black
In the first sample test the white queen can capture the black queen at the first move, so the white player wins.
In the second test from the statement if the white queen captures the green pawn located on the central vertical line, then it will be captured by the black queen during the next move. So the only move for the white player is to capture the green pawn located at (2, 1).
Similarly, the black queen doesn't have any other options but to capture the green pawn located at (2, 3), otherwise if it goes to the middle vertical line, it will be captured by the white queen.
During the next move the same thing happens — neither the white, nor the black queen has other options rather than to capture green pawns situated above them. Thus, the white queen ends up on square (3, 1), and the black queen ends up on square (3, 3).
In this situation the white queen has to capture any of the green pawns located on the middle vertical line, after that it will be captured by the black queen. Thus, the player who plays for the black queen wins.
Note
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
int main()
{
int n;
cin>>n;
if(n%==)
cout<<"black"<<endl;
else
{
cout<<"white"<<endl;
cout<<"1 2"<<endl;
}
return ;
}
Codeforces Round #281 (Div. 2) D. Vasya and Chess 镜面对称 博弈论的更多相关文章
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 水
D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈
D. Vasya and Chess Vasya decided to learn to play chess. Classic chess doesn't seem interesting to ...
- Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题
B. Vasya and Wrestling 题目连接: http://codeforces.com/contest/493/problem/B Description Vasya has becom ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 暴力水题
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力水题
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序
C. Vasya and Basketball Vasya follows a basketball game and marks the distances from which each te ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力
A. Vasya and Football Vasya has started watching football games. He has learned that for some foul ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)
简单题,却犯了两个错误导致WA了多次. 第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的... 二是chronologically这个词 ...
随机推荐
- shell脚本编程之“最简单的死循环”【转】
转自:http://blog.chinaunix.net/uid-23046336-id-3475462.html 在linux下编程的程序猿都知道shell脚本,就算你不怎么熟悉,也应该听过的吧!那 ...
- MySQL5.7之多源复制&Nginx中间件(下)【转】
有生之年系列----MySQL5.7之多源复制&Nginx中间件(下)-wangwenan6-ITPUB博客http://blog.itpub.net/29510932/viewspace-1 ...
- Deploy Openstack all-in-one Shell Script
Deploy Openstack all-in-one Shell Script At present(2015/10), the RDO deploment method can only inst ...
- 一张图教会CSS3倒影
分享 示例图片 在CSS3之前,想要实现示例图片这样的一个倒影效果一般只能通过处理图片的方式,而CSS3问世之后,想要实现这样的效果变得非常简单,只需一个CSS3属性就可以轻松实现了. 这就是今天所要 ...
- 九、springboot整合redis二之缓冲配置
1.创建Cache配置类 @Configuration @EnableCaching public class RedisCacheConfig extends CachingConfigurerSu ...
- (五)HttpClient 连接超时及读取超时
第一节: HttpClient 连接超时及读取超时 HttpClient连接超时及读取超时 httpClient在执行具体http请求时候 有一个连接的时间和读取内容的时间: HttpClient连接 ...
- performance 判断页面是以哪种方式进入的
if (window.performance) { console.info("window.performance is supported"); console.log(per ...
- 经典面试题:n个数字(0,1,…,n-1)形成一个圆圈
题目: n个数字(0,1,…,n-1)形成一个圆圈,从数字0开始, 每次从这个圆圈中删除第m个数字(第一个为当前数字本身,第二个为当前数字的下一个数字). 当一个数字删除后,从被删除数字的下一个继续删 ...
- Java第三阶段学习(三、字符流、转换流)
一.字节流读取中文时出现的问题: 文件中有中文时,用字节流读取会出现乱码的问题,因为一个中文为两个字节. 二.字符编码表 编码表:其实就是生活中字符和计算机二进制的对应关系表. 1.ascii: 一个 ...
- TCP和UDP的9个区别是什么
TCP和UDP是两个传输层协议,广泛应用于网络中不同主机之间传输数据.对任何程序员来说,熟悉TCP和UDP的工作方式都是至关重要的.这就是为什么TCP和UDP是一个流行的Java编程面试问题.我曾经在 ...