#P2348. 三国杀I(洗牌&发牌)

三国杀I(洗牌&发牌)

Description

A game of Sanguosha has nn players, and each player needs 44 cards. The deck has kk cards, which must be shuffled before dealing. Each card has the following 33 attributes:

  1. Card type:

    1. Basic: Sha (K\texttt{K}), Shan (M\texttt{M}), Tao (P\texttt{P}), Jiu (W\texttt{W}).
    2. Non-delayed tactic: Juedou (B\texttt{B}), Wanjian (A\texttt{A}), Nanman (S\texttt{S}), Wugu (C\texttt{C}), Taoyuan (G\texttt{G}), Chai (D\texttt{D}), Shun (U\texttt{U}), Tiesuo (T\texttt{T}), Wuxie (N\texttt{N}), Huogong (F\texttt{F}), Wuzhong (E\texttt{E}).
    3. Delayed tactic: Bing (I\texttt{I}), Le (K\texttt{K}), Shandian (L\texttt{L}).
    4. Mounts (+,-\texttt{+,-}).
    5. Weapon: Liannu (LN\texttt{LN}), Qinggang (QG\texttt{QG}), Guding (GD\texttt{GD}), Hanbing (HB\texttt{HB}), Cixiong (CX\texttt{CX}), Wuliu (WL\texttt{WL}), Qinglong (QL\texttt{QL}), Zhangba (ZB\texttt{ZB}), Guanshi (GS\texttt{GS}), Fangtian (FT\texttt{FT}), Yushan (YS\texttt{YS}), Qilin (LG\texttt{LG}).
    6. Armor: Renwang (RW\texttt{RW}), Bazhen (BZ\texttt{BZ}), Tengjia (TJ\texttt{TJ}), Shizi (SZ\texttt{SZ}).
  2. Suit: one of C,H,S,D\texttt{C,H,S,D}.

  3. Rank: one of A,2,3,4,5,6,7,8,9,T,J,Q,K\texttt{A,2,3,4,5,6,7,8,9,T,J,Q,K} (T stands for 10, in ascending order).

Shuffling method: After one shuffle, from top to bottom the order becomes $\left\lfloor\dfrac{k}{2}\right\rfloor+1, 1, \left\lfloor\dfrac{k}{2}\right\rfloor+2, 2, \left\lfloor\dfrac{k}{2}\right\rfloor+3, 3, \ldots, k, \left\lfloor\dfrac{k}{2}\right\rfloor$ (if there is an odd number of cards, the last extra card is simply ignored).

Dealing method: Starting from the 11-st card, from top to bottom give the ii-th card to player [(i1)modn+1][(i-1)\mod n+1].

Given that the deck is shuffled mm times in total, determine which 44 cards are dealt to player pp.

Input Format

The input has k+1k+1 lines.

The first line contains 44 positive integers n,k,m,pn, k, m, p.
Then follow kk lines, each with two strings. In the first string, the first character is the suit and the second character is the rank; the second string is the card type. When outputting the player’s cards, use the same format.

The meanings of n,k,m,pn, k, m, p are as described above.

Output Format

Output 44 lines, each with one string, representing the 44 cards owned by player pp (each line must include the card’s suit, rank, and type, in the same format as the input).

If there are not enough cards, output Error:cards not enough.

2 10 1 1
C2 K
H5 B
DT K
SA M
HQ P
D4 K
C6 P
H9 M
ST B
SK C

D4 K
C6 P
H9 M
ST B

2 7 1 1
C2 K
H5 B
DT K
SA M
HQ P
SK C
C6 P

Error:cards not enough

Hint

Constraints: For 100%100\% of the testdata, $1\leqslant p\leqslant n\leqslant 1000, 1\leqslant k\leqslant 100000, 1\leqslant m\leqslant 80$.

Translated by ChatGPT 5