#K94657. Taco Key-Value Storage Simulation

    ID: 38690 Type: Default 1000ms 256MiB

Taco Key-Value Storage Simulation

Taco Key-Value Storage Simulation

In this problem, you are required to simulate a simple key-value storage system that supports three operations:

  • ADD key value: Insert or update the key with the given value.
  • GET key: Retrieve the value associated with the key. If the key does not exist, output None.
  • DELETE key: Remove the key from the storage if it exists.

You will be given multiple datasets. For each dataset, process the operations sequentially and output the result of every GET operation in the order they appear. After processing each dataset, output an extra blank line as a delimiter.

For example, consider a dataset with the following operations:

ADD 1 10
GET 1
DELETE 1
GET 1

The corresponding output should be:

10
None

Note that in the above, the first GET returns 10 while the second returns None (since the key has been deleted), and an empty line is printed after processing the dataset.

Formally, if you denote the number of datasets as \(T\) and for each dataset you have \(N\) operations, then your program should process each dataset independently. For every dataset:

Let \(S\) be the storage after processing all operations. For every GET key command, output \(S(key)\) if \(key \in S\) or output "None" otherwise. Finally, output a blank line as a separator.

inputFormat

The first line contains a single integer \(T\), the number of datasets.

For each dataset, the first line contains an integer \(N\), the number of operations.

This is followed by \(N\) lines, each containing an operation in one of the following formats:

  • ADD key value
  • GET key
  • DELETE key

outputFormat

For each dataset, output the result of each GET operation on a new line. After processing each dataset, output an additional blank line (i.e. an empty line) to separate the outputs of different datasets.

## sample
1
4
ADD 1 10
GET 1
DELETE 1
GET 1
10

None

</p>