logo AlgoBeat OnlineJudge
登录 注册

#215520. [USACO26FEB] Point Elimination S

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You have ( is even points () on an infinite 2D-coordinate plane.

You can perform the following two types of operations any number of times:

  • Choose two points that are directly adjacent to each other (manhattan distance of ), and remove both points.
  • Choose any two points and swap their y-coordinates. Formally, points and become and respectively.

Determine if it is possible to eliminate all points on the board. Note that it may be the case that two points may map to the same coordinate; they should still be treated as different points. You also may not directly delete points on the same coordinate, as they are technically not directly adjacent.

输入格式

The first line contains (), the number of test cases.

The first line of each test case contains an integer .

The following lines contain two integers and .

It is guaranteed that the sum of over all test cases does not exceed .

输出格式

For each test case, output "YES" or "NO" on a new line.

样例

样例输入 1

4
2
1 1
1 1
4
6 10
7 11
8 1
8 1
6
1 2
1 3
1 4
1 5
10 10
11 10
6
1 1
1 1
1 1
1 1
10 10
11 11

样例输出 1

NO
YES
YES
NO

数据范围与提示

For the first test, the only two points are equal, so no swaps will do anything. Thus, our answer is NO.

In the second test, we can swap the y-coordinates of 6 and 7 with 8 and 8. Then, we can remove the first two points (horizontal adjacency) and the last two (vertical).

For the third test, no swaps are needed. We can remove the first pair, second, and third.

In the last test, it can be shown that no matter how we swap the y-coordinates, we will never be able to remove all the points in adjacent pairs.

SCORING:

  • Input 2: ,
  • Inputs 3-5:
  • Inputs 6-11: No additional constraints.

Problem credits: Alex Pylypenko, Chongtian Ma