P5645 [PKUWC2018] Dou Dizhu
Background
Dou Dizhu is a poker game played with a full deck of $54$ cards: ranks from A to K in four suits (spades, hearts, clubs, diamonds), plus two Jokers (one small Joker and one big Joker). Each Joker appears once, and every other rank appears four times. In Dou Dizhu, the rank order is defined as follows: $3
Description
Now three people are playing Dou Dizhu. If the Landlord achieves Spring, then the Landlord is considered the winner; otherwise, even if the Landlord plays all their cards first, it is still considered a win for the Farmers. Assume all three players act with optimal decisions.
You are given $n(0 \leq n\leq 20)$ cards. Ask how many possible initial hands of the Landlord contain these $n$ cards, and no matter how the Farmers’ cards are distributed, the Landlord is guaranteed to achieve Spring.
Input Format
The first line contains an integer $t$ indicating the number of test cases.
For each test case, one line is given. The first integer is $n$, the number of fixed cards, followed by $n$ space-separated integers describing each fixed card.
In particular, we use $1$ to represent rank A, $11$ for rank J, $12$ for rank Q, $13$ for rank K, $14$ for the small Joker, and $15$ for the big Joker. The input is guaranteed to be valid, meaning that the count of each rank will not exceed its count in a full deck.
Output Format
For each test case, output one integer, the number of Landlord hands that satisfy the condition. The answer may be very large; output it modulo $998244353$.
**Note**: In this problem we ignore suits. If two hands have exactly the same multiset of ranks but different suits, they are considered the same.
Explanation/Hint
#### Sample Explanation
For the first sample, we can see that the Farmers cannot have a Bomb or Rocket, so the Landlord can first play $[3,4,5,6,7,8,9,10,J,Q]$ (clearly neither Farmer can beat it), then play $[2,2]$, then play the big Joker, then play $[K,K,K,K,A,J]$, and finally play $[8]$.
| ID | $n$ | $t$ |
| :--: | :----------: | :------: |
| 1 | $=20$ | $= 100$ |
| 2 | $=18$ | $= 100$ |
| 3 | $=16$ | $= 100$ |
| 4 | $=14$ | $= 100$ |
| 5 | $=12$ | $= 100$ |
| 6 | $=0$ | $= 1$ |
| 7 | $=0$ | $= 1$ |
| 8 | $\in [0,20]$ | $= 500$ |
| 9 | $\in [0,20]$ | $= 1000$ |
| 10 | $\in [0,20]$ | $= 2000$ |
Translated by ChatGPT 5