#P16399. [ECUSTPC 2026 Spring] 朝复习
[ECUSTPC 2026 Spring] 朝复习
Background
:::epigraph Computer Science: Review (Computer Science: Go Over, known as ___ ) is something popular around the world. :::
Problem Description
This problem is unrelated to Problem H "Morning Review, Evening Review".
TSUCE (Time-Space Union of Coding Experts) is going to hold the TSUCE Programming Duel Cup, a head-to-head algorithm contest between two players.
The rules are as follows. Please pay attention to the meanings of and :
- Each match is played between two players. In each match, there is exactly one winner, and there are no draws.
- A match consists of one regulation period plus several overtime periods (possibly overtime periods). The regulation period contains rounds. Each overtime period contains rounds. In each round, there is exactly one winner.
- During regulation, the player who gets round wins will win the whole match, and the match ends immediately.
- If there is still no winner after the rounds of regulation (the score is ), the match enters overtime. In a single overtime period, the player who gets round wins will win the whole match, and the match ends immediately.
- If there is still no winner after one overtime period, the match enters the next overtime period, until a winner is decided.
- The final score is the number of rounds each side wins in the whole match.
Unfortunately, scorekeeper Little T’s database broke. He only remembers the scores of all matches, but he does not remember the and related to the rules.
Please help him determine whether there exists a pair of valid positive integers and such that all these scores are valid under this rule set.
Input Format
The first line contains an integer , the number of testdata.
For each testdata, the first line contains an integer , the number of recorded matches.
Then follow lines, each containing two integers and , representing the score of a match recorded in Little T’s database.
It is guaranteed that over all testdata.
Output Format
For each testdata, if there exists a valid and such that all these scores are valid under this rule set, output one line with the string YES; otherwise output one line with the string NO.
Note that the judge is case-insensitive for YES and NO. In other words, if the answer is positive, outputs like yes, YES, Yes, YeS, etc. will all be accepted.
6
3
16 14
10 16
19 22
2
11 16
19 22
5
2 13
16 12
9 13
13 10
20 22
2
5 7
5 9
3
0 5
5 2
11 7
2
6 9
9 6
YES
YES
YES
NO
YES
YES
Hint
Sample 1 Explanation
For the 3rd testdata, we can find that is a valid solution. Then the matches may go through the following process:
- Match 1: . During regulation, player B first reaches wins and ends the match.
- Match 2: . Regulation ends in a tie. In the first overtime period, player A wins and gets wins.
- Match 3 and Match 4 end in regulation with scores and , respectively.
- Match 5: Regulation ends in a tie. In both the first and second overtime periods, the score is , so the match reaches and enters the third overtime period. Finally, player B wins in the third overtime period, and the final score is A B.
Translated by ChatGPT 5