CF734D Anton and Chess
题目描述
Anton喜欢下棋与编程,所以他决定写一个国际象棋游戏。然而,他认为8x8的棋盘太简单了,因此这个棋盘是无限大的。
他的第一个任务是检查当前状态下是否被将军,他并不知道如何实现这点,因此向你求助。
棋盘上有一个白色方的王与n个黑色方的棋子,它们仅由车、象和后组成。当至少一个黑色方的棋子可以在一步内移动到白色方王所在的格子时被视为将军。
帮助Anton写一个程序,在给定所有棋子的位置时判定白色方的王是否被将军。
以下是各种棋子的移动方式:
- 象可以斜着移动,格子不限。
- 车可以水平或垂直移动,格子不限。
- 后可以水平、垂直或斜着移动,格子不限。
- 所有的棋子不能越过已经占用的格子。
输入格式
第一行包含一个整数n(1
输出格式
输出由一行组成:如果被将军,则输出"YES"(不带引号),否则输出"NO"(不带引号)。
说明/提示
Picture for the first sample:
 White king is in check, because the black bishop can reach the cell with the white king in one move. The answer is "YES".Picture for the second sample:
 Here bishop can't reach the cell with the white king, because his path is blocked by the rook, and the bishop cant "leap" over it. Rook can't reach the white king, because it can't move diagonally. Hence, the king is not in check and the answer is "NO".