2974 - CS2351_DS_24Spring_Quiz1 Scoreboard

Time

2024/04/01 18:30:00 2024/04/01 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team
1 14265 - Gold Miner (Hacked) judgeDS_2018 Announcement We might put an update description above Example Animation, so you might want to refresh from time to time judgeDS_2018 2024/04/01 18:59:20

# Problem Pass Rate (passed user / total user)
14265 Gold Miner (Hacked)

14265 - Gold Miner (Hacked)   

Description

Important Notice: Those who haven't filled in the google form in the pinned announcement (eLearn) quickly fill it.


Silver Wolf being the mischievous hacker she is, hacks into the OJ system and modified the problem from Homework1. Originally the things that can be found were:

 Symbol   -    Full Name

  1. D    -    Diamond

  2. G    -    Gold

  3. B    -    Bomb

  4. F    -    Flashlight

  5. M   -    Magnet

  6. C   -    Lucky Clover

  7. P   -    Pig

  8. _   -    Empty

But she removed Bomb, Flashlight, Magnet, and the Lucky Clover, while adding Virus, Shovel, Coin, and Strange Button. So the things that can be found now are:

 Symbol   -    Full Name

  1. D    -    Diamond

  2. G    -    Gold

  3. S    -    Shovel

  4. V    -    Virus

  5. C    -    Coin

  6. P    -    Pig

  7. X    -    Strange Button

  8. _    -    Empty

Object Descriptions

In general, the things mentioned above are divided into 3 types: Collectibles, Items, and Entities.

Collectibles

Diamond - Same usage and rule as homework1, when you dig it you put it in your Backpack.

Gold - Same usage and rule as homework1, when you dig it you put it in your Backpack.

Items

Shovel - It will go to your Item Inventory after being dug. When used, you directly dig the last selected location twice. If there’s no path left then do nothing. Multiple Shovels may exist in the map.

Strange Button - It will go to your Item Inventory after being dug. When used, a wall of collectibles will appear at the end of the map (right most side) with Gold appearing on odd index, and Diamond on even. Multiple Buttons may exist in the map.

Coin - It will not go to your Item Inventory after being dug, you are free to implement how to store it. Cannot be used by the player, will automatically get used as a protective measure against Pig and when used, print out “Ding!” with a new line. There can only be 1 Coin in the map.

Entities

Virus - If you were to dig into a Virus, it’s game over! You directly stop all operations and just print out “Game Over!” with a new line followed by printing the whole map with the rule explained below. There can only be 1 Virus in the map.

Pig - Silver Wolf changes the Pig into a Space Pig! Somehow it is not interested in Diamonds but in Gold instead, if you Dig a Pig then it will steal all of your Gold, or unless you have it’s favorite thing, the Coin then it will be satisfied with only taking your Coin. I guess it likes shiny yellow thingy more than Diamonds. Multiple Pigs can exist in the map.

Game Descriptions

Silver Wolf also modified how the Player can dig, now instead of digging from top to bottom, we dig from left to right. For the Item Inventory, it is reversed, we use the newest item first, leaving the oldest item the last in sequence.

The rest of the Player's moving rules are the same as homework, which is “DIG [idx]” and “USE”.

Inventory is for items. Backpack is for collectibles.

 

This is a normal judge problem.

You are allowed to use STL in this problem. 

Without further ado, time to start coding!

 
 
Hint

Debug the input

Before trying the problem, you should try out whether your input processing method is correct or not.

Check sample output

You can download the sample output and see the proper format by checking whether there’s space on the end of the line or if there’s a newline.

 

Update:

18:52 The L is 1 <= L <= 15
18:55 Sample input "B" changed to "G"
19:12 You print "Game Over!" only if you dig virus, if the program ends without digging virus you print the given format (the backpack, inventory, map)
 
Example Animation 

Input

Same format with homework.

The first line contains three integers:

  1. Integer R representing the number of columns on the map.

  2. Integer L representing the number of rows on the map.

  3. Integer N, representing the number of actions the Player will do.

Starting from the second line, there are L lines each containing R characters. The R characters in each line are separated by a space between each of them, each character represents an object. Overall, in the initial state of the game, there will be at most R x L items on the map. The empty space in the grid of the stage that doesn't contain any item will be represented by a “_”. You must implement the map by creating an array/vector of queues! You’re not allowed to use a 2D array/vector.

Following the L lines will be N lines, each representing the action the Player will take. Each of these N lines starts with an action string Ai. There will be only 2 available actions: DIG and USE.

DIG will let the user input a number which specifies the position (row) where he wants to dig, if it is an invalid position, do nothing. While USE will directly let the user use the most recent Item the Player gets, if the Item Inventory is empty, then do nothing.

 

Output

When Player uses a DIG, if they find Virus print “Game Over!” with a new line and then followed by the rule below, if a Pig is found and the Player is protected by Coin, print “Ding!” with a new line. Anything else you don’t have to print anything.

If the player already finished moving N times or they DIG Virus, print your content of Backpack in the sequence of the first item you obtained to the last in the format: “Backpack:“ followed by the rest of the collectibles symbol separated with spaces.

Example: “Backpack: G D D G” (Format is [Space][Item] not [Item][Space]) and print a new line at the end.

Then also print the Inventory with exactly the same way as Backpack.

Example: “Inventory: S X S” (Format is [Space][Item] not [Item][Space]) and print a new line at the end.

After that, print the current state of the map with the format: “Map:”, a new line, then the map with format [Object][Space][Object][Space] (don’t forget the new line at the end). If the map is empty, still print everything inside the map (so basically you will print out a matrix of ‘_’).

Example if there's object in map: 

Map:

_ _ G G D 

_ P _ G D 

_ V _ X C 

S _ G G G 

 <----- there's an empty new line here

 

Example if map is empty:

Map:

_ _ _ _ 

_ _ _ _ 

_ _ _ _ 

 <----- there's an empty new line here

Sample Input  Download

Sample Output  Download

Tags




Discuss