#C13239. Adventure Game Simulation

    ID: 42755 Type: Default 1000ms 256MiB

Adventure Game Simulation

Adventure Game Simulation

In this problem, you are asked to simulate a simple adventure game. The game world consists of three rooms: the Living Room, the Kitchen, and the Bedroom. They are connected as follows: the Living Room is connected to the Kitchen to the north, the Kitchen is connected back to the Living Room to the south and to the Bedroom to the east, and the Bedroom is connected to the Kitchen to the west. Initially, the Living Room contains the item key. A player starts in the Living Room and can execute the following commands via standard input:

  • move <direction>: Move the player in the specified direction. Valid directions are north, south, east, and west.
  • pick_up <item>: Pick up an item from the current room.
  • use_item <item>: Use an item from the player's inventory.
  • save: Save the current game state (current room and inventory).
  • load: Load the most recently saved game state.

When moving, if the specified direction is valid for the current room, the program outputs: Moved to ROOM_NAME.. If the movement is invalid, output You can't go that way!.

When picking up an item, if the item exists in the room, output Picked up ITEM.; otherwise, output No ITEM here..

When using an item, if it is in the inventory, output You used ITEM.; otherwise, output You don't have ITEM..

The commands save and load simulate saving and restoring the game state and will output Game Saved. and Game Loaded. respectively. Note that there is only one save slot.

For example, the formula for energy is given by: E=mc2E=mc^2.

inputFormat

The first line of input contains an integer Q (1 ≤ Q ≤ 1000), the number of commands. Each of the next Q lines contains a command, which can be one of the following forms:

• move • pick_up • use_item • save • load

The player's initial state and room connections are predefined as in the problem statement.

outputFormat

For each command that produces an output, print a line to standard output. The output should exactly match the expected responses as described in the problem statement.## sample

6
move north
pick_up key
move south
pick_up key
use_item key
use_item map
Moved to Kitchen.

No key here. Moved to Living Room. Picked up key. You used key. You don't have map.

</p>