#P6529. Missing Cards

    ID: 19742 Type: Default 1000ms 256MiB

Missing Cards

Missing Cards

You are given a string representing a set of playing cards. Each card is denoted by a three‐character code. The first character represents the suit, which can be one of P, K, H, or T. The following two characters represent the card number from 01 to 13.

Your task is to determine how many cards are missing from each suit in a full deck (each suit should have 13 cards). If you detect any duplicate card in the input, simply output GRESKA and ignore the rest.

Formally, let \(C(s)\) be the number of cards of suit \(s\) that appear in the input. For each suit \(s\) in the order P, K, H, T, your output should be:

[ 13 - C(s) \quad \text{for each suit } s \in {P, K, H, T}. ]

inputFormat

The input consists of a single line containing a string whose length is a multiple of 3. Each contiguous block of 3 characters represents a card code. It is guaranteed that the card number is between 01 and 13.

outputFormat

If any duplicate cards are found, output GRESKA. Otherwise, output four numbers separated by a space, corresponding to the number of missing cards in suits P, K, H, and T respectively.

sample

P01K02H03H04
12 12 11 13