plutolove’s diary

I love three things in this world, the sun, the moon and you. The sun for the day, the moon for the night, and you forever。

Codeforces Round #281 Div. 2 D. Vasya and Chess

題目連接:http://codeforces.com/contest/493/problem/D

題意

給定一個n*n的棋盤,白皇后在(1,1)黑皇后在(1,n),其他位置擺放的是綠色中立棋子
遊戲規則:

  • 白皇后先走
  • 與皇后在同一條直線或對角線上則皇后可以吃掉該位置的棋子并移動到該位置
  • 如果某一個皇后沒有棋子可以吃或者被另一個皇后吃掉則該皇后輸

解法

博弈
n是奇數時,將中心y=n/2+1看做對稱軸,白皇后先走
白皇后走一步,黑皇后跟著移動到與之對稱的的點,最後肯定是白皇后走到對稱軸,黑皇后吃掉白皇后
n是偶數時,白皇后走到(1,2)這個點,情況轉變為(n-1)*(n-1)的棋盤,黑皇后先走,必敗

n=int(input());
if n%2==1:  print("black");
else: print("white\n1 2");