#abc299b. B - Trick Taking
B - Trick Taking
Score : points
问题描述
名玩家,编号为 ID 号 ,正在进行一场纸牌游戏。
每位玩家出一张牌。
每张牌有两个参数:颜色 和 点数,两者都用正整数表示。
对于 ,玩家 出的牌的颜色为 ,点数为 。所有 都互不相同。
在 名玩家中,将根据以下规则决定一名 胜者。
- 如果有一张或多张颜色为 的牌被打出,那么在这几张牌中点数最大的玩家即为胜者。
- 如果没有颜色为 的牌被打出,则在所有与玩家 打出的牌颜色相同的牌中,点数最大的玩家为胜者。(注意,玩家 有可能获胜)
输出胜者的 ID 号。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
players with ID numbers are playing a card game.
Each player plays one card.
Each card has two parameters: color and rank, both of which are represented by positive integers.
For , the card played by player has a color and a rank . All of are different.
Among the players, one winner is decided as follows.
- If one or more cards with the color are played, the player who has played the card with the greatest rank among those cards is the winner.
- If no card with the color is played, the player who has played the card with the greatest rank among the cards with the color of the card played by player is the winner. (Note that player may win.)
Print the ID number of the winner.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4 2
1 2 1 2
6 3 4 5
Sample Output 1
4
Cards with the color are played. Thus, the winner is player , who has played the card with the greatest rank, , among those cards.
Sample Input 2
4 2
1 3 1 4
6 3 4 5
Sample Output 2
1
No card with the color is played. Thus, the winner is player , who has played the card with the greatest rank, , among the cards with the color of the card played by player (color ).
Sample Input 3
2 1000000000
1000000000 1
1 1000000000
Sample Output 3
1
update @ 2024/3/10 12:24:01