#arc171a. A - No Attacking

A - No Attacking

Score: 400400 points

问题陈述

有一个 NNNN 列的棋盘。用 (i,j)(i, j) 表示从顶部数第 ii 行,从左边数第 jj 列的方格。 现在你将在棋盘上放置棋子。有两种类型的棋子,分别称为 。 当棋子的放置满足以下条件时,称为一个 好的排列

  • 每个方格上放置的棋子数量为零或一。
  • 如果在 (i,j)(i, j) 处有一个车,那么对于所有 kk (1kN)(1 \leq k \leq N) 其中 kjk \neq j(i,k)(i, k) 处没有棋子。
  • 如果在 (i,j)(i, j) 处有一个车,那么对于所有 kk (1kN)(1 \leq k \leq N) 其中 kik \neq i(k,j)(k, j) 处没有棋子。
  • 如果在 (i,j)(i, j) 处有一个兵,并且 i2i \geq 2,那么 (i1,j)(i-1, j) 处没有棋子。

在棋盘上以好的排列放置所有的 AA 个车和 BB 个兵是否可能?

给出了 TT 个测试用例;解决每一个。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

There is a chessboard with NN rows and NN columns. Let (i,j)(i, j) denote the square at the ii-th row from the top and the jj-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 (i,j)(i, j), there is no piece at (i,k)(i, k) for all kk (1kN)(1 \leq k \leq N) where kjk \neq j.
  • If there is a rook at (i,j)(i, j), there is no piece at (k,j)(k, j) for all kk (1kN)(1 \leq k \leq N) where kik \neq i.
  • If there is a pawn at (i,j)(i, j) and i2i \geq 2, there is no piece at (i1,j)(i-1, j).

Is it possible to place all AA rooks and BB pawns on the board in a good arrangement?

You are given TT test cases; solve each of them.

Constraints

  • 1T1051 \leq T \leq 10^5
  • 1N1041 \leq N \leq 10^4
  • 0A,B0 \leq A, B
  • 1A+BN21 \leq A + B \leq N^2
  • All input values are integers.

Input

The input is given from Standard Input in the following format. Here, casei\mathrm{case}_i represents the ii-th case.

TT

case1\mathrm{case}_1

case2\mathrm{case}_2

\vdots

caseT\mathrm{case}_T

Each test case is given in the following format.

NN AA BB

Output

Print TT lines. The ii-th line should contain the answer for the ii-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 (1,1)(1, 1) and (2,4)(2, 4), and pawns at (3,3)(3, 3), (4,2)(4, 2), and (5,3)(5, 3) 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.

}