#P16587. [GKS 2016 #C] Soldiers
[GKS 2016 #C] Soldiers
题目描述
General Alice and General Bob are playing a war game. There are soldiers in the game. Each soldier has two stats: attack and defense.
Before the game starts, General Alice and General Bob will take turns selecting soldiers, with General Alice going first. In each turn, a player can select one soldier, as long as that soldier either has an attack stat greater than each of the attack stats of all soldiers selected so far, or has a defense stat greater than each of the defense stats of all soldiers selected so far. To be precise: let and be the attack and defense values for the -th soldiers, for i from 1 to , and let be the set of soldiers that have been selected so far. Then a player can select soldier if and only if at least one of the following is true:
- for all in
- for all in
If no selection can be made, then the selection process ends and the players start playing the game.
General Alice wants to select more soldiers than General Bob, and General Bob wants to avoid that. If both players play optimally to accomplish their goals, can General Alice succeed?
输入格式
The first line of each case contains a positive integer , the number of soldiers. more lines follow; the i-th of these line contains two integers and , indicating the attack and defense stats of the -th soldier.
输出格式
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is YES or NO, indicating whether General Alice can guarantee that she selects more soldiers than General Bob, even if General Bob plays optimally to prevent this.
3
3
10 2
1 10
10 3
3
10 1
10 10
1 10
3
10 2
1 10
4 9
Case #1: NO
Case #2: YES
Case #3: YES
提示
Limits
;
.
Small dataset (Test set 1 - Visible)
.
Large dataset (Test set 2 - Hidden)
.