#C13199. Simulated DynamoDB Table Operations

    ID: 42710 Type: Default 1000ms 256MiB

Simulated DynamoDB Table Operations

Simulated DynamoDB Table Operations

In this problem, you are required to simulate a simple DynamoDB table that supports four basic operations: CREATE, READ, UPDATE, and DELETE. Each record in the table consists of three fields: an identifier (id), a name, and an age. All operations will be provided as commands via standard input, and you must output the response for each command to standard output.

The operations are defined as follows:

  1. (\textbf{CREATE id name age}): Insert a new item into the table. If an item with the given id does not exist, add it and output Created. If the id already exists, output Error.

  2. (\textbf{READ id}): Retrieve the item with the given id. If the item is found, output its details in the format: id name age. Otherwise, output NotFound.

  3. (\textbf{UPDATE id newAge}): Update the age of the item with the given id. If the item exists, update its age and output Updated; if not, output NotFound.

  4. (\textbf{DELETE id}): Remove the item with the given id from the table. If deletion is successful, output Deleted; otherwise, output NotFound.

The input begins with an integer that represents the number of operations to perform. Each subsequent line contains one operation. Your program must process these operations sequentially and output the result of each operation on a new line.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (T) representing the number of operations. Each of the following (T) lines contains an operation command in one of the following formats:

  • CREATE id name age
  • READ id
  • UPDATE id newAge
  • DELETE id

Each field is separated by a space.

outputFormat

Output the result of each operation on a new line to standard output (stdout). The expected responses for the operations are:

  • For CREATE: output Created if the item is successfully created; otherwise, output Error if an item with the same id already exists.
  • For READ: if the item exists, output it in the format id name age; if it does not exist, output NotFound.
  • For UPDATE: output Updated if the item exists and is updated; otherwise, output NotFound.
  • For DELETE: output Deleted if the item is successfully removed; otherwise, output NotFound.## sample
6
CREATE 123 TestUser 30
READ 123
UPDATE 123 31
READ 123
DELETE 123
READ 123
Created

123 TestUser 30 Updated 123 TestUser 31 Deleted NotFound

</p>