MWC '15 #5 P2: WildCard

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 3.0s
Memory limit: 256M

Author:
Problem type

aurpine and kushanzaveri are playing a game called WildCard. In this game, N cards are placed face up, adjacent to one another. Each card has a special integer representing its wild factor W_i. On each player's turn, they must find a pair of any two cards which have a combined wild factor of exactly K. Once a pair is found, the two cards are removed from the game, and the next player's turn starts. The player who cannot make a valid pair of two cards on their turn loses the game.

As both aurpine and kushanzaveri are amateurs and take a long time to complete a single game, you want to write a program that can calculate the result of their game.

Input Specification

On one line, three space separated integers N (1 \le N \le 10^6), K (1 \le K \le 10^9) and T (0 \le T \le 1), with T representing the player who goes first (0 being aurpine and 1 being kushanzaveri).

On the second line, N space separated integers representing W_i (1 \le W_i \le 10^8), the wild factor of the i^\text{th} card.

Output Specification

On one line output the name of the player who wins the game as well as the number of pairs that he can make, separated by a space.

Sample Input

6 10 1
1 5 2 8 3 9

Sample Output

aurpine 1

Explanation of Sample Output

If kushanzaveri goes first, he can choose to make one of two pairs: (2, 8) or (1, 9). Either way, after both players each play one turn (each player making one of the valid pairs), there will be no more valid pairs to make and aurpine will win having made one pair.


Comments


  • -2
    vincentdmacri  commented on April 29, 2016, 3:05 a.m. edited

    If K = 10^9, there will be no pairs, since card can't be higher than 10^8. Since someone solved this already, I guess it's a typo. Which value has a mistake?


    • 1
      atarw  commented on April 29, 2016, 1:24 p.m. edit 5

      The player who cannot make a valid pair of two cards on their turn loses the game.

      No mistake was made.


  • 1
    Daniel123  commented on April 23, 2016, 8:12 p.m.

    Do the cards have distinct wild factors?


    • 3
      atarw  commented on April 23, 2016, 8:26 p.m. edited

      Don't assume anything not explicitly stated :D (they don't have to be unique)