#K73982. Manage Unique IDs
Manage Unique IDs
Manage Unique IDs
You are given a sequence of requests to manage a set of unique identifiers.
Each request is in one of the following two forms:
+ x
: Add the identifier x to the set.- x
: Remove the identifier x from the set.
The responses for each request are defined as follows:
- If
+ x
is requested and x is not present in the set, output Added. - If
+ x
is requested and x is already present in the set, output Already present. - If
- x
is requested and x is present in the set, output Removed. - If
- x
is requested and x is not present in the set, output Not found.
The operations are performed sequentially. For every request, print the corresponding result on a new line.
Note: The identifiers x are integers. The addition and removal operations are performed in order. In formal notation, if we denote the set as \( S \), then \[ \text{If } request = '+ x': \quad S = S \cup \{x\}, \quad \text{{output}} = \begin{cases} "Added" & \text{if } x \notin S \\ "Already present" & \text{if } x \in S \end{cases} \] \[ \text{If } request = '- x': \quad S = S \setminus \{x\}, \quad \text{{output}} = \begin{cases} "Removed" & \text{if } x \in S \\ "Not found" & \text{if } x \notin S \end{cases} \]
inputFormat
The first line contains an integer \( n \) representing the number of requests. Each of the following \( n \) lines contains a request in the format "+ x
" or "- x
", where x is an integer identifier.
outputFormat
For each request, output a single line with the corresponding response, which will be one of the following strings: "Added", "Already present", "Removed", or "Not found".
## sample5
+ 12345
+ 67890
- 12345
- 11111
+ 67890
Added
Added
Removed
Not found
Already present
</p>