#C12078. Tournament Registration and Query System
Tournament Registration and Query System
Tournament Registration and Query System
You are given a series of queries for managing a coding tournament registration system. There are two types of queries:
- Type 1: Registration query. The query is formatted as:
1 ID Types
. This registers a participant with a unique integer identifierID
and a stringTypes
representing the contest types the participant is registering for (e.g. 'A', 'B', 'C', or their combinations). The order of characters inTypes
does not matter (e.g. 'AC' is equivalent to 'CA'). - Type 2: Retrieval query. The query is formatted as:
2 Types
. For this query, you must output a single line: a space-separated list of participant IDs that are registered exactly with the combination of contest types provided (after sorting the characters inTypes
). The IDs should be printed in increasing order. If no participant is found, print-1
.
Note: Input is read from STDIN and output is printed to STDOUT.
inputFormat
The first line of input contains an integer Q representing the number of queries. The next Q lines each contain a query. A query is either in the format 1 ID Types
for a registration query or 2 Types
for a retrieval query.
outputFormat
For each retrieval query (queries starting with 2), output the result on a new line. The result is either a space-separated list of participant IDs (in increasing order) or -1
if no participant is found for that contest type combination.
11
1 1 A
1 2 B
1 3 C
1 4 AB
1 5 BC
1 6 CA
1 7 ABC
2 A
2 AB
2 BC
2 AC
1
4
5
6
</p>