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这个词 ...
随机推荐
- Linux内核跟踪之trace框架分析【转】
转自:http://blog.chinaunix.net/uid-20543183-id-1930846.html ---------------------------------------- ...
- python网络编程--线程使用threading
一:线程使用 线程使用有两种方法,一种是直接使用,二是通过继承threading.Thread类使用 二:函数式使用 函数式:调用thread模块中的start_new_thread()函数来产生新线 ...
- urllib2使用初探
在入门urllib2之前,我想应该先调研一下urllib与urllib2的区别[1].首先我们要明白的是,这两个模块不可以相互替代.两者都是接受URL请求的模块,但是提供了不同的功能,两个显著的区别是 ...
- java基础49 IO流技术(对象输入流/对象输出流)
1.对象输入输出流 对象注意作用是用于写对象信息与读取对象信息 1.对象输出流:ObjectOutputStream 2.对象输入流:ObjectInputStream 2.对象输入输出流的步骤 ...
- MyEclipse自带且常用的快捷键和自己定义的快捷键方法步骤
1.MyEclipse自带且常用的快捷键 内容提示(补全): Alt+/ 导包快捷键: Ctrl+Shift+o 格式化代码: Ctrl+Shift+f 行代码位置上下调换: Alt ...
- Eclipse 配置语言环境
一.打开https://www.eclipse.org/babel/downloads.php 选择一下版本的Bable(通天塔) 选择 解压 打开Eclipse 软件 选择Help->inst ...
- Linux 命令find、grep
本文就向大家介绍find.grep命令,他哥俩可以算是必会的linux命令,我几乎每天都要用到他们.本文结构如下: find命令 find命令的一般形式 find命令的常用选项及实例 find与xar ...
- MySQL学习笔记:创建整年日期
见识到另外一种创意,惊讶! 1.创建小数据表 0-9 # 创建小数据表 DROP TABLE IF EXISTS aa_numbers_small; CREATE TABLE aa_numbers_s ...
- Effective STL 学习笔记 Item 26: Prefer Iterator to reverse_iterator and const_rever_itertor
Effective STL 学习笔记 Item 26: Prefer Iterator to reverse_iterator and const_rever_itertor */--> div ...
- JOIN从句
MySQL基础表和数据 -- 5条数据 select * from test_a; -- 8条数据 select * from test_b; 内连接 -- 内连接,join,为inner join的 ...