#arc171a. A - No Attacking
A - No Attacking
Score: points
问题陈述
有一个 行 列的棋盘。用 表示从顶部数第 行,从左边数第 列的方格。 现在你将在棋盘上放置棋子。有两种类型的棋子,分别称为 车 和 兵。 当棋子的放置满足以下条件时,称为一个 好的排列:
- 每个方格上放置的棋子数量为零或一。
- 如果在 处有一个车,那么对于所有 其中 , 处没有棋子。
- 如果在 处有一个车,那么对于所有 其中 , 处没有棋子。
- 如果在 处有一个兵,并且 ,那么 处没有棋子。
在棋盘上以好的排列放置所有的 个车和 个兵是否可能?
给出了 个测试用例;解决每一个。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There is a chessboard with rows and columns. Let denote the square at the -th row from the top and the -th column from the left.
You will now place pieces on the board. There are two types of pieces, called rooks and pawns.
A placement of pieces is called a good arrangement when it satisfies the following conditions:
- Each square has zero or one piece placed on it.
- If there is a rook at , there is no piece at for all where .
- If there is a rook at , there is no piece at for all where .
- If there is a pawn at and , there is no piece at .
Is it possible to place all rooks and pawns on the board in a good arrangement?
You are given test cases; solve each of them.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format. Here, represents the -th case.
Each test case is given in the following format.
Output
Print lines. The -th line should contain the answer for the -th test case.
For each test case, print Yes
if it is possible to place the pieces in a good arrangement and No
otherwise.
Sample Input 1
8
5 2 3
6 5 8
3 2 2
11 67 40
26 22 16
95 91 31
80 46 56
998 2 44353
Sample Output 1
Yes
No
No
No
Yes
No
Yes
Yes
In the first test case, for example, you can place rooks at and , and pawns at , , and to have all the pieces in a good arrangement.
In the second test case, it is impossible to place all the pieces in a good arrangement.