eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Crazy Bishops

Crazy Bishops

When studying chess, many people are first taught how to checkmate the lone king. In this problem you have to check whether it is possible to checkmate the lone black king with two bishops and a king, starting from a given position. Recall that a king can move one cell in each of the eight directions, a bishop can move any number of cells in diagonal direction. A king cannot move to the cell that is attacked by some piece. A bishop can move to any cell, but he must not move to the cell that is attacked by the black king, if it is not protected, in other case it can be taken by the black king and the game ends in draw. Given the position on the board and the side that has the turn, you have to detect whether white can win, or black can force the game to end in draw. Remember, that if the black king has no possible moves, but is not checkmated (i.e. it is stalemated), the game is considered to end in draw. \InputFile The first line of the input file contains cells where white king and two bishops are located, respectively. The second line contains the cell where the black king is located. Standard chess notation is used, letters '\textbf{a}' to '\textbf{h}' stand for verticals and digits '\textbf{1}' to '\textbf{8}' for horizontals. The last line contains "\textbf{white}" if it’s white’s turn and "\textbf{black}" if it’s black’s turn. The position is guaranteed to be valid, i.e. no king can be taken on the current turn. \OutputFile Output "\textbf{white wins}" if white can win, and "\textbf{draw}" if it cannot.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
c2 a4 c1
a2
white
Вихідні дані #1
white wins
Джерело Russian Teams Training Sessions in Petrozavodsk, Summer 2004, Andrew Stankevich Contest 8, Thursday, August 26, 2004