luogu#P12117. [NWRRC2024] Misère
[NWRRC2024] Misère
题目描述
\textit{Préférence} is a card game which is very popular in Eastern Europe. It is usually played with a 32-card deck, which consists of pip cards from 7 to 10, Jack, Queen, King, and Ace in each of the four suits: Spades, Clubs, Diamonds, and Hearts. In each round of the game, three players receive ten cards each, and two cards are left on the table as a talon. Then, a phase of auction happens, where players make their bids, which are obligations to take at least a certain number of tricks. A special case of a bid is a so-called \textit{misère}, which is an obligation to take no tricks regardless of other players' moves.
In this task, we will consider a special modification of préférence which is played with a modified deck containing cards, where is a number of suits, and is the number of ranks in each suit. For example, the standard 32-card deck for the préférence game has suits and ranks. For convenience, we'll number the suits from to , and the ranks from to .
You need to solve a puzzle about this modification of préférence. In this modification, we'll say that a misère is \textit{guaranteed} if for every suit, after we order the cards belonging to this suit in your hand by their rank as (where is the number of cards of the suit in your hand), the following condition is satisfied: for all from to . If you don't have any cards of the suit (), the condition is trivially satisfied.
You have cards in your hand, and you will be allowed to choose any cards you don't have and add them to your hand. Then, you must select any of your cards and drop them, leaving some cards in your hand. Your task is to find the smallest possible such that you can transform your hand to a guaranteed misère.
2
4 2 6
1 1
1 2
1 6
2 3
2 4 5
3 4
2 4
1
2