#B3767. Card Game Rounds
Card Game Rounds
Card Game Rounds
Two players, Fusu and XiaoF, each hold (n) cards initially. Each card has a suit (f) and a point (p). In this problem, the suit is a positive integer not exceeding (m), and the point is a positive integer not exceeding (r).
A round is played as follows:
-
The player who starts the round plays the card with the smallest point. If there are multiple cards with the same smallest point, the one with the smallest suit is played. (Formally, the card chosen is the one minimizing ((p, f)) in lexicographical order.)
-
Then the two players alternate turns. On a turn, the current player must play a card from his hand that has the same suit as the opponent’s last played card and a point strictly greater than that card. Among such cards, the one with the smallest point is chosen.
-
If a player cannot play a card on his turn, the round ends immediately, and the next round starts with the player who played the last card in the ended round.
The game continues round by round until one of the players has no cards left. Your task is to determine who will be the first to empty his hand.
The game rules can be summarized by the following conditions:
- Let (n) be the number of cards each player holds initially, (m) the maximum suit value, and (r) the maximum point value.
- The first move in a round: play the card with minimum (p) (and if tied, the minimum (f)).
- Subsequent moves: play the card of the same suit as the opponent’s last card with the smallest (p) that is greater than the opponent’s last card point.
- When a player cannot play a card, the round ends and the player who played the last card starts the next round.
- The game ends when one player runs out of cards; output that player (print "Fusu" if player 0 empties his hand first, or "XiaoF" if player 1 does).
inputFormat
Input is given as follows:
The first line contains four integers (n), (m), (r), and (s), where (n) is the number of cards each player has, (m) is the maximum suit value, (r) is the maximum point value, and (s) is either 0 or 1 indicating the player who starts the first round (0 for Fusu, 1 for XiaoF).
The next (n) lines each contain two integers (f) and (p), representing the suit and point of Fusu's cards.
The following (n) lines each contain two integers (f) and (p), representing the suit and point of XiaoF's cards.
outputFormat
Output a single line containing either "Fusu" or "XiaoF" indicating the player who first empties his hand.
sample
2 5 10 0
1 3
2 5
1 4
2 6
XiaoF