#C4560. Dictionary Data Structure Operations

    ID: 48112 Type: Default 1000ms 256MiB

Dictionary Data Structure Operations

Dictionary Data Structure Operations

This problem requires you to implement a simple dictionary data structure that supports three operations: insertion, deletion, and search. The operations are given in a specific format:

  • I key value: Insert the key with the given integer value. If the key already exists, update its value.
  • D key: Delete the key from the dictionary. If the key does not exist, do nothing.
  • S key: Search for the key. If found, output its associated value; otherwise, output \( -1 \).

You will be given a series of operations. For every search operation, output the result. All formulas, if present, follow the LaTeX format.

inputFormat

The input is read from standard input. The first line contains an integer (n), representing the number of operations. The following (n) lines each contain an operation command in one of the three formats described above.

outputFormat

For every search operation (command starting with 'S'), output the resulting integer on a new line. The result is either the value associated with the key or ( -1 ) if the key does not exist.## sample

5
I apple 5
I orange 10
S apple
S orange
S banana
5

10 -1

</p>