CF1737C.Ela and Crickets
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述

Ela likes Chess a lot. During breaks, she usually challenges her co-worker in DTL to some chess games. She's not an expert at classic chess, but she's very interested in Chess variants, where she has to adapt to new rules and test her tactical mindset to win the game.
The problem, which involves a non-standard chess pieces type that is described below, reads: given 3 white crickets on a n⋅n board, arranged in an "L" shape next to each other, there are no other pieces on the board. Ela wants to know with a finite number of moves, can she put any white cricket on the square on row x, column y?
An "L"-shape piece arrangement can only be one of the below:




For simplicity, we describe the rules for crickets on the board where only three white crickets are. It can move horizontally, vertically, or diagonally, but only to a square in some direction that is immediately after another cricket piece (so that it must jump over it). If the square immediately behind the piece is unoccupied, the cricket will occupy the square. Otherwise (when the square is occupied by another cricket, or does not exist), the cricket isn't allowed to make such a move.
See an example of valid crickets' moves on the pictures in the Note section.

Ela 非常喜欢国际象棋。休息时,她通常会向同事 DTL 发起一些国际象棋对局挑战。她并非传统国际象棋的专家,但她对国际象棋变体非常感兴趣——在这些变体中,她需要适应新规则,并运用自己的战术思维来赢得比赛。
本题涉及一种非标准的棋子类型(具体定义如下):给定一个 n×n 的棋盘,其上有 3 枚白蟋蟀(cricket),彼此紧邻排成一个“L”形;棋盘上无其他任何棋子。Ela 想知道:经过有限步移动后,能否将其中某一枚白蟋蟀移动至第 x 行、第 y 列的方格上?
“L”形排列仅可能是以下四种情形之一:




为简化问题,我们仅考虑棋盘上仅有这三枚白蟋蟀的情形。蟋蟀的走法规则如下:它可沿水平、垂直或对角线方向移动,但仅能跳至某个方向上紧邻另一枚蟋蟀之后的空格(即必须跳过该蟋蟀)。若该“紧邻之后”的方格为空,则蟋蟀将占据该方格;否则(即该方格已被另一枚蟋蟀占据,或该方格根本不存在),则不允许进行此次移动。
有关蟋蟀合法移动的示例,请参见“注”部分中的图示。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains n (4≤n≤105) — denotes the size of the chessboard.
The second line of each test case contains 6 numbers: r1, c1, r2, c2, r3, c3 (1≤r1,c1,r2,c2,r3,c3≤n) — coordinates of the crickets. The input ensures that the three crickets are arranged in an "L" shape that the legend stated.
The third line of each test case contains 2 numbers: x, y (1≤x,y≤n) — coordinates of the target square.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(4≤n≤105),表示棋盘的大小。
每个测试用例的第二行包含 6 个数字:r1, c1, r2, c2, r3, c3(1≤r1,c1,r2,c2,r3,c3≤n),表示三只蟋蟀的坐标。输入保证这三只蟋蟀按传说中所述构成一个“L”形。
每个测试用例的第三行包含 2 个数字:x, y(1≤x,y≤n),表示目标方格的坐标。
输出格式
For each test case, print "YES" or "NO" to denotes whether Ela can put a cricket on the target square.
对于每个测试用例,输出 “YES” 或 “NO”,表示 Ela 是否能在目标方格上放置一只蟋蟀。
输入输出样例
输入#1
6 8 7 2 8 2 7 1 5 1 8 2 2 1 2 2 1 5 5 8 2 2 1 2 2 1 6 6 8 1 1 1 2 2 1 5 5 8 2 2 1 2 2 1 8 8 8 8 8 8 7 7 8 4 8
输出#1
YES NO YES NO YES YES
说明/提示
Here's the solution for the first test case. The red square denotes where the crickets need to reach. Note that in chess horizontals are counted from bottom to top, as well as on this picture.

以下是第一个测试用例的解答。红色正方形表示蟋蟀需要到达的位置。注意,在国际象棋中,横坐标(行)是从下往上计数的,图中也是如此。

输入解题思路,AI测评打分。不知道怎么写?