2017 Fall Waterloo Local ACM Contest, Problem B
Vera has cards. Each card has a rank, an integer between and , and a suit, an integer between and . All cards are distinct. A set of five different cards is known as a hand. Each hand is in exactly one of nine categories numbered from to . If a hand satisfies the conditions for membership in multiple categories, it is considered to be in the lowest-numbered such category. The rules for each category are:
- Straight flush: is a Straight and a Flush.
- Four of a kind: four of the cards have the same rank.
- Full house: three of the cards have the same rank and the remaining two have the same rank.
- Flush: all five cards have the same suit.
- Straight: the ranks of the cards in increasing order are for some integer .
- Three of a kind: three of the cards have the same rank.
- Two pair: two cards have the same rank and two other cards have the same rank.
- One pair: two cards have the same rank.
- High card: if a hand does not satisfy any other category.
Currently, Vera has two cards with ranks and suits . Of the remaining cards, Vera will choose three more cards and form a hand with her two current cards. Compute the number of different hands formed in this way that belong in each category.
Input
Line contains integers and .
Line contains integers .
Output
Print one line with nine integers, the number of different hands that belong in each category in increasing order of categories (from Straight flush to High card).
Sample Input 1
5 2
1 0 3 1
Sample Output 1
0 0 0 0 8 0 12 36 0
Sample Input 2
13 4
0 0 1 0
Sample Output 2
1 2 18 164 63 308 792 7920 10332
Note
Let denote a card with rank and suit .
For the first example, Vera currently has cards and . If she chooses additional cards , her hand will be a Two pair as there are two cards with rank 3 and two other cards with rank 4. Note that this hand also satisfies being a One pair, but Two pair is the lower-numbered category.
Comments