Jadie Wadie's Ladies
Jaiden, also known as Jadie Wadie, loves to play poker. Jaiden's favourite hand in poker is when he has two queens, also known as the ladies in poker slang.
There are cards total, arranged in a specific, fixed order that Jaiden knows in advance. Exactly
of these
cards are queens; the rest are irrelevant to Jaiden's goal. There are also
players, which includes Jaiden himself.
Normally, a dealer removes the card from the top of the deck to hand to a player. Jaiden however is good at sleight of hand, so in addition to a "normal deal" described earlier, he can also do a "bottom deal", where he removes a card from the bottom of the deck and deals it. Since this game is very casual, Jaiden can deal the cards out in whatever order he likes so long as each player recieves 2 cards in the end.
How many unique sets of cards allow Jaiden to deal himself two queens while dealing no queens to anyone else?
Input
The first line consists of 3 integers ,
and
, the number of cards in the deck, the number of queens in the deck, and the number of players.
,
,
The next line consists of integers
or
, the order of the cards in the deck, read from the top of the deck to the bottom.
's represent that the card is a queen, and
's represent any other type of card.
Output
Output a single integer, the number unique sets of cards Jaiden can deal so that he can deal himself two queens and deal no one else in the game any queens. A set of cards is defined by the number of cards dealt from the top and the number of cards dealt from the bottom. Two sets are unique if either number differs.
Examples
Input 1
8 2 2
1 0 0 0 0 0 1 0
Output 1
2
The first way Jaiden can achieve this is by dealing card from the top, and
cards from the bottom.
The second way Jaiden can achieve this is by dealing cards from the top, and
cards from the bottom.
Input 2
8 2 2
0 0 0 1 1 0 0 0
Output 2
0
Comments