Girls Invitational '18 S4 - Reppoh Ecarg

View as PDF

Submit solution

Points: 12
Time limit: 2.0s
Memory limit: 64M

Problem type

In Ada Land a common pastime is the card game Reppoh Ecarg. It is played with a deck of cards which contains \(N\) cards each with a positive integer value written on it. The game’s rules are very simple. First, you pick a card with any number written on it. The value of the next card you pick must be a factor of this card’s value, or must have this card’s value as a factor of its own. The game continues until all possible jumps from one card to another have been completed, in which case the player wins, or until there are no more legal moves, in which case the player loses. Keep in mind that a jump from card \(A\) to card \(B\) invalidates a jump from card \(B\) to card \(A\).

Unfortunately, there has recently been a malfunction in the factory that produces the Reppoh Ecarg decks, and some cards have been misprinted; some of the cards have had wrong numbers printed on them. You have been tasked with discarding all the unbeatable decks. Can you do it?

Input Specification

The first line will contain \(T\ (1 \le T \le 10)\), the number of decks.
There will follow \(T\) deck descriptions.
The first line of each deck will contain \(N\ (1 ≤ N ≤ 500)\) and \(K\ (1 ≤ K ≤ 50)\).
The next line will have \(N\) space separated integers, no greater than \(K\).

Output Specification

\(T\) lines of one string, Keep if the deck is beatable or Discard if it is not.

Sample Input 1

5 6
1 2 3 4 6

Sample Output 1


Sample Input 2

6 6
1 2 2 3 3 6
3 3
1 2 3

Sample Output 2



There are no comments at the moment.