#P2668. [NOIP 2015 提高组] 斗地主
[NOIP 2015 提高组] 斗地主
Description
Niuniu has recently become obsessed with a card game called Dou Dizhu. Dou Dizhu is a card game played with a standard deck consisting of spades, hearts, clubs, and diamonds from to , plus the two jokers, for a total of cards. In Dou Dizhu, the rank order of the cards is represented by their face values as follows: $3<4<5<6<7<8<9<10<J<Q<K<A<2<\text{small Joker}<\text{big Joker}$, and suits do not affect the rank. In each round, a hand consists of cards. Each turn, a player may play according to the allowed patterns. The first player to play all of their cards wins the game.
Now, Niuniu only wants to know, for several sets of hands, the minimum number of plays required to play out each of them. Please help him solve this problem.
Note that in this problem, the playable patterns per turn are similar to those in standard Dou Dizhu but slightly different. The specific rules are as follows:

The testdata for this problem is random and hacks are not supported. To hack or use stronger testdata please click here.
Input Format
The first line contains two positive integers separated by a space, representing the number of hand sets and the number of cards in each hand.
Then follow groups of data. Each group contains lines, each line containing a pair of nonnegative integers representing a card, where is the rank and is the suit, separated by a space. Specifically, we use to represent rank , to represent rank , to represent rank , and to represent rank ; spades, hearts, clubs, and diamonds are represented by –, respectively; the small joker is represented by 0 1, and the big joker is represented by 0 2.
Output Format
Output lines. Each line contains an integer representing the minimum number of plays needed to play out the -th hand set.
1 8
7 4
8 4
9 1
10 4
11 1
5 1
1 4
1 1
3
1 17
12 3
4 3
2 3
5 4
10 2
3 3
12 2
0 1
1 3
10 1
6 2
12 1
11 3
5 2
12 4
2 2
7 2
6
Hint
Sample 1 explanation:
There is hand set with cards: diamond , diamond , spade , diamond , spade , spade , diamond , and spade . You can finish in plays by playing a straight of singles (diamond , diamond , spade , diamond , spade ), a single (spade ), and a pair (spade and diamond ).
For different test points, we define the scales of the number of hand sets and the number of cards as follows:
| Test point ID | ||
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | ||
| 9 | ||
| 10 | ||
| 11 | ||
| 12 | ||
| 13 | ||
| 14 | ||
| 15 | ||
| 16 | ||
| 17 | ||
| 18 | ||
| 19 | ||
| 20 |
It is guaranteed that all hands are randomly generated.
Translated by ChatGPT 5
京公网安备 11011102002149号