View as PDF

Points:5
Time limit:1.0s
Memory limit:256M
Author:

Problem type

You are in English class and learning about paradoxen. Unbeknownst to the teacher, the set<bool> data structure is incredibly useful to determine whether or not a situation/statement is a paradox. Implement a set<bool> interface for your teacher!

You are given commands, each in the following 4 forms:

1. 1 E insert element E into the set. Print true or false depending on whether or not the element was successfully inserted (did it not exist in the set before?).
2. 2 E erase element E from the set. Print true or false depending on whether or not the element was successfully erased (did it exist in the set before?).
3. 3 E find element E in the set. Print the index of the element within the set (0-indexed). If the element does not exist, print -1.
4. 4 print the elements in increasing order. (false true)

For each command, print a single line of output. E will be either true or false.

Sample Input

5
1 true
2 false
3 false
1 false
4


Sample Output

true
false
-1
true
false true


• ThePenguinCo
commented on Sept. 17, 2016, 10:26 p.m.
Picky input

Picky input, I also overcomplicated this :P

• paydayzcool
commented on Sept. 16, 2016, 10:57 p.m. edited
What if the set is empty and the input is "4"?

What if the set is empty and the input is "4"? Do I put a newline or just nothing?

EDIT: nvm I solved it. I missed the print("true") on one of the lines facepalm

• println_hi_
commented on Oct. 15, 2016, 1:30 p.m.

I believe its a newline, about to find out for myself

• jlsajfj
commented on Sept. 16, 2016, 6:14 p.m.
Well

I way over complicated this and p1...