P5370 [PKUSC2018] Zhu Dou Di

Description

If you have taken part in NOIP 2015 and PKUWC 2018, you must have a deep impression of a problem called Dou Dizhu. To pay tribute to the classic, we made another card-related problem. In this problem, the hand types are **similar to but not exactly the same as** Dou Dizhu. We call the poker game in this problem Zhu Dou Di. Zhu Dou Di is a poker game played with a total of 54 cards: A to K of spades, hearts, clubs, and diamonds, plus the small joker and the big joker, one each. All other ranks have four copies. In Dou Dizhu, the order of ranks is as follows: $3

Input Format

For each test case, input one line: a string of length $17$ representing the “×× netizen”’s hand. We use 456789TJQKA2wW to represent each rank of card.

Output Format

For each test case, output an integer representing the answer: the number of Jiutiao Kelian’s hands that satisfy the condition. The answer may be very large, so 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 still considered the same.

Explanation/Hint

For various reasons, this problem uses bundled testdata. There are $3$ subtasks in total: | Subtask ID | Score | Constraint | | :---: | :--: | :------------: | | 1 | $30$ | Each rank appears at most $2$ times | | 2 | $30$ | Each rank appears at most $3$ times | | 3 | $40$ | Each rank appears at most $4$ times | Time limit: 2s. Memory limit: 512M. Translated by ChatGPT 5