#P2348. Card Distribution in Three Kingdoms Kill
Card Distribution in Three Kingdoms Kill
Card Distribution in Three Kingdoms Kill
This problem is about dealing cards in a game similar to Three Kingdoms Kill. There are \( n \) players and a deck of \( k \) cards, each card having three attributes: type, suit and rank. The types include various categories with symbols such as K, M, P, W, B, A, S, C, G, D, U, T, N, F, E, I, K, L, +, -
and others like LN, QG, GD, HB, CX, WL, QL, ZB, GS, FT, YS, LG, RW, BZ, TJ, SZ
. The suit is one of C, H, S, D
and the rank is one of A,2,3,4,5,6,7,8,9,T,J,Q,K
(T stands for 10).
The deck is shuffled \( m \) times. One shuffle is performed as follows. Assume the deck has \( k \) cards with \( \lfloor k/2 \rfloor \) denoting the integer part of \( k/2 \). Then after one shuffle the new order of cards from top to bottom is:
[ \left\lfloor\frac{k}{2}\right\rfloor+1,\ 1,\ \left\lfloor\frac{k}{2}\right\rfloor+2,\ 2,\ \ldots,\ k,\ \left\lfloor\frac{k}{2}\right\rfloor ]
If \( k \) is odd, the last card is ignored. After shuffling, the cards are dealt one by one from the top of the deck. The \( i \)-th card is given to the player \( ((i-1) \mod n) + 1 \). Each player receives 4 cards. You are to determine the 4 cards received by the \( p \)-th player.
inputFormat
The first line contains four integers \( n \), \( k \), \( m \), and \( p \) separated by spaces, representing the number of players, the number of cards in the deck, the number of shuffles, and the target player's number (1-indexed), respectively.
Each of the following \( k \) lines describes one card. Each line contains three tokens: the card's type, suit, and rank, in that order. The deck order is given from top to bottom.
outputFormat
Output 4 lines. Each line contains the type, suit, and rank of a card (separated by spaces) that the \( p \)-th player receives, in the order they are dealt.
sample
3 12 1 2
K C A
M H 2
P S 3
W D 4
B C 5
A H 6
S S 7
C D 8
D C 9
U H T
T S J
LN D Q
K C A
D C 9
W D 4
LN D Q
</p>