#P16587. [GKS 2016 #C] Soldiers

    ID: 16560 Type: RemoteJudge 2000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 7 Uploaded By: Tags>动态规划 DP博弈论2016Google Kick Start

[GKS 2016 #C] Soldiers

题目描述

General Alice and General Bob are playing a war game. There are NN 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 AiA_i and DiD_i be the attack and defense values for the ii-th soldiers, for i from 1 to NN, and let SS be the set of soldiers that have been selected so far. Then a player can select soldier xx if and only if at least one of the following is true:

  • Ax>AsA_x > A_s for all ss in SS
  • Dx>DsD_x > D_s for all ss in SS

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 NN, the number of soldiers. NN more lines follow; the i-th of these line contains two integers AiA_i and DiD_i, indicating the attack and defense stats of the ii-th soldier.

输出格式

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy 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

1T101 \le T \le 10;

1Ak,Dk100001 \le A_k, D_k \le 10000.

Small dataset (Test set 1 - Visible)

1N2001 \le N \le 200.

Large dataset (Test set 2 - Hidden)

1N40001 \le N \le 4000.