#C84. Stone Collection Manager
Stone Collection Manager
Stone Collection Manager
You are given an initial collection of stone names and a series of queries. For each query, if the stone already exists in the collection, output Found
; otherwise, add the stone to the collection and output Added
.
This task tests your ability to efficiently manage a dynamic set of items. Using appropriate data structures will help ensure that membership queries and insertions are handled quickly.
Note that the expected output for each query is printed on a new line.
inputFormat
The input is provided through stdin and follows the format below:
- The first line contains an integer n, the number of initial stones in the collection.
- The next n lines each contain a string representing a stone name.
- The following line contains an integer q, the number of queries.
- The next q lines each contain a string representing a stone query.
outputFormat
For each query, print Found
if the stone is already in the collection, or Added
if it has been newly added. Each result is printed on a separate line to stdout.
3
Amethyst
Quartz
Topaz
4
Ruby
Amethyst
Emerald
Amethyst
Added
Found
Added
Found
</p>