#K43137. Efficient Number Set Operations
Efficient Number Set Operations
Efficient Number Set Operations
You are provided with a series of operations to perform on a set of integers. The operations are defined as follows:
- Add (Query Type 1): Add an integer \(x\) to the set. It is guaranteed that \(x\) is not already present in the set.
- Remove (Query Type 2): Remove an integer \(x\) from the set. It is guaranteed that \(x\) is present in the set.
- Check (Query Type 3): Check if an integer \(x\) is present in the set. Print
YES
if it is present andNO
otherwise.
You will be given \(n\) queries. Process these queries sequentially, and for each query of type 3, output the result as described above.
inputFormat
The input begins with an integer \(n\) on the first line, representing the number of queries. Each of the next \(n\) lines contains two space-separated integers \(t\) and \(x\), where \(t\) indicates the type of operation (1, 2, or 3), and \(x\) is the integer to be processed.
outputFormat
For every query of type 3, output the result on a new line. The output should be YES
if \(x\) is present in the set at the time of the query, and NO
otherwise.
6
1 5
1 10
3 5
2 5
3 5
3 10
YES
NO
YES
</p>