Ben was having a great time
self-advertising playing his own game, Classified, when he suddenly encountered a strange bug which caused him to somehow lose. After months of interrogation, he soon realized that the cause of his loss was not a bug, but simply him being bad at his own game. Since Ben was so tired of losing over, and over, and over again, he has asked YOU to perform this task for him - Create a program which will output the highest amount of damage that he can deal to his opponent, in a single turn, given the cards in your hand, and the current cards on the playfield.
Assume that all current cards on the playfield have been placed beforehand on a previous turn, and that cards in your hand have the same stats as they do in the collection.
Classified is a tower-defense, turn-based card game developed by the greatest programmer of all time, Ben Zeng, where two players take turns placing down cards from their "hand" by using their cash, onto a ~5~ column by ~6~ row playfield (~6~ in terms of vertical height, ~5~ in terms of horizontal width). For our case, we will be playing on a smaller grid, which will be ~2~ columns instead of ~5~.
Each player has a deck consisting of ~N~ cards, however for the sake of simplicity, only one player's deck is considered for this problem.
Each card has 4 unique base attributes,
Movement, as well as side-attributes
Attackrepresents the amount of damage the card will deal to another card when landing an attack.
Healthrepresents the amount of damage the card can take before being removed off of the playfield. If a card has
12 Health, for example, and a card with
5 Attackdeals an attack towards this card, it will have
Rangerepresents how far vertically a card can attack from. For example, if you were to attack a card on the tile directly above one of your cards, that would require the card to have a
Rangevalue of ~1~. Cards can attack either forward, or backwards on any given tile.
Movementrepresents how far vertically a card can move. For example, if you were to move a card to the tile directly up from where it currently is, that would require the card to have a
Movementvalue of ~1~. Cards can move either forward, or backwards on any given tile.
Costrepresents how much cash the card requires in order to be placed down. Once the card is placed down, your cash value will decrease by the amount the card costs.
Playerrepresents which player placed down the cards. You can only attack cards which are NOT yours, and only perform actions, such as moving and attacking, using cards that ARE yours.
- Cards placed down by Ben MUST be on row 1.
- Obviously, cards cannot be placed on a tile that is already occupied by another card.
- Cards placed down by Ben, or cards that Ben has already placed down, can each individually perform ONE of the following moves:
- Move to a valid tile that is within the boundaries of the playfield. Your cards cannot move over other cards. If there is any card "in the way" of your card and your tile, this tile is not considered a valid destination.
- Attack one of your opponents' cards. Your cards cannot attack over cards that do not belong to you.
- Deal damage to your opponent directly. In order for one of your cards to be able to directly attack your opponent, the
Rangeof the card must be greater than the difference between Row 6 and the current row that your card is on. Another way to think of this, is as if there was a card on the 7th row (Note that there can't actually be cards here), in the same column that you are attacking from. Same general rules apply with attacking cards.
- Attacks must never deal a negative amount of damage. If a specific card reduces damage by ~5~, and the damage being dealt is ~3~, it will deal ~0~ damage, not ~-2~ damage.
- Upon a card's death, the destroyed card should get removed from the playfield after all card effects have been taken into consideration. This means that if the card that is being destroyed has a relevant special effect, per say, "attacking whichever card tried to attack it", this effect will still occur.
Collection of Cards
Like any tower defense card game, Classified has a predetermined collection of cards, which already have specific
Cost. Along with these 5 universal stats, each card also has a name, which determines not only the card's base stats, but also the card's special ability. Below are the list of the cards in the collection.
|yeahbennou||9||26||3||3||8||Upon place: All of your cards (Including this card) gain 6 attack. This buff stays even if this card dies, or has its ability removed.|
|A.L.I.C.E.||10||20||3||3||10||While alive: All of your cards take 10 less damage from all attacks.|
|astrocat879||9||12||1||1||8||While alive: When any of your cards get hit, this card will first attack the aggressor, and then take 2 damage. Upon death: deal 4 damage to all of your opponent's cards.|
|Waba359||7||15||1||4||6||Special: This card is a splash AOE attacker. This means that when attacking a card, the attack will "splash" onto the 8 surrounding adjacent tiles. In other words, this card will deal damage to all of your opponents' cards in a 3 by 3 radius. Remember that you cannot direct an attack towards an empty tile, even if there are cards adjacent to this tile.|
|Ben 2.0||5||28||2||2||9||While alive: All of your opponents' attacks will be redirected to this card and deal half (rounded down) damage, given that they are attacking something other than Ben 2.0.|
|saltyRavioli||3||7||2||5||4||Upon place: "push back" every single one of your opponents' cards as far back as possible (For Ben's case, this is row 6). Cards already near the end get pushed "first", meaning that if there were two of your opponents' cards in the same column, the one closer to row 6 would get pushed to row 6, and the other card would get pushed to row 5.|
|hewmatt10||4||15||1||1||7||While alive: Every one of your cards on this card's column (Including this card itself), have +2 range.|
|kenneth_ruan||7||9||2||2||4||Upon place: All of your cards gain +2 attack. While alive: Newly placed cards gain +2 attack. In addition to gaining attack, cards with a 't' or 'T' in their name will also gain +1 range.|
|AlanL||5||12||4||2||2||Special: This card can attack and move in the same turn.|
|nicoella||10||13||2||3||5||When killing a card: Gain $3.|
|dulldesk||7||13||3||2||4||Upon place: target the most expensive one of your opponents' cards and remove its special ability. If there are multiple cards with the same price, target the one which was placed latest.|
- You are guaranteed that there will never be multiple Ben 2.0s on the field.
- You are also guarunteed that there will never be multiple astrocat879s on the field.
- However, there may be cases where both Ben 2.0 and astrocat879 is on the field.
The first line will contain two integers, ~N~ ~(0 \le N \le 3)~, and ~M~ ~(0 \le M \le 20)~, where ~M~ represents the amount of money Ben has to place down cards.
The second line will contain ~N~ strings, ~s_1, s_2, \dots, s_N~, where ~s_i~ is the name of the card in Ben's deck. Note that the stats of this card are the base stats, located in the collection above.
The third line will contain a single integer, ~C~ ~(0 \le C \le 3)~.
The next ~C~ lines will contain a string ~s~, followed by ~7~ spaced integers, ~x,~ ~y,~ ~a,~ ~h,~ ~m,~ ~r,~ ~p~ ~(1 \le x \le 2),~ ~(1 \le y \le 6),~ ~(0 \le a \le 100),~ ~(0 \le h \le 100),~ ~(1 \le m \le 5),~ ~(1 \le r \le 6),~ ~(1 \le p \le 2)~, indicating the name and stats of a card that has been preplaced on the playfield. ~s~ represents the card's name, ~x, y~ represent which column and row the card is on, respectively, ~a, h, m, r~ represent the card's attack, health, movement, and range, and ~p~ represents the player possession of the card, where ~1~ is player 1, (Ben), and ~2~ is his opponent.
A single integer, representing the highest amount of damage Ben can deal to his opponent.
Sample Input 1
1 8 yeahbennou 1 A.L.I.C.E. 1 6 10 20 3 3 1
Sample Output 1
A.L.I.C.E. already starts out on Row 6, this card is well in range of attacking the player with its ~10~ base damage. To maximize damage, Ben should place down
yeahbennou to increase
A.L.I.C.E.'s damage to ~16~.
Sample Input 2
3 15 hewmatt10 saltyRavioli yeahbennou 1 yeahbennou 2 6 7 12 3 3 2
Sample Output 2
Currently, there are none of your cards on the playfield. This means that in order to do damage, cards must be placed. Since all the cards in the hand currently cannot move and attack in the same turn, and cards must be placed on Row 1, the only way to deal damage is to have a card with at least ~6~ range. To do this, you can place a
hewmatt10 in Column 1, to not get blocked by the opponent's
yeahbennou, then you can move the
hewmatt10 up, and place a
saltyRavioli right behind.
saltyRavioli has a base range of ~5~, and with the range buff given by the
hewmatt10 in the same column/lane, it will have enough range in order to directly attack the opponent for ~3~ damage.
Sample Input 3
0 0 3 astrocat879 1 4 1 1 1 1 2 yeahbennou 1 1 100 2 1 6 1 yeahbennou 1 2 100 4 1 6 1
Sample Output 3
Regardless of which
yeahbennou you attempt to attack with, the death effect of the
astrocat879 will destroy both of the
yeahbennou, preventing either of them from attacking.
Sample Input 4
0 0 3 astrocat879 1 4 1 1 1 1 2 yeahbennou 1 1 100 2 1 6 1 yeahbennou 1 2 100 5 1 6 1
Sample Output 4
Unlike with sample 3, one of the
yeahbennou has ~5~ health, meaning that it can barely survive the death damage of the
yeahbennou with ~2~ health can simply attack the
astrocat879 blocking the way of attacking the player, destroying it, leaving the
yeahbennou with ~5~ health able to attack the player directly, for ~100~ damage.
Sample Input 5
2 11 dulldesk hewmatt10 3 astrocat879 1 4 1 1 1 1 2 yeahbennou 1 2 100 2 1 2 1 yeahbennou 1 3 100 4 1 2 1
Sample Output 5
By placing down the
dulldesk, the opponent's
astrocat879 will no longer have its ability, meaning that its death effect will not occur anymore. After this, you can safely attack the
astrocat879 with one of the
yeahbennou with no issues. However, neither of them will have the range in order to attack the player yet, so placing down the
hewmatt10 on Column 1 is neccesary.