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 E
insert elementE
into the set. Printtrue
orfalse
depending on whether or not the element was successfully inserted (did it not exist in the set before?).2 E
erase elementE
from the set. Printtrue
orfalse
depending on whether or not the element was successfully erased (did it exist in the set before?).3 E
find elementE
in the set. Print the index of the element within the set (0-indexed). If the element does not exist, print-1
.4
print the elements in increasing order (false
<true
).
E
will be either true
or false
.
Input Specification
Output Specification
For each command, print a single line of output.
Sample Input
5
1 true
2 false
3 false
1 false
4
Sample Output
true
false
-1
true
false true
Comments
there can be a maxinmum of 1 true and 1 false in the set? is that what "(did it not exist in the set before?)." means?
When you attempt to insert a value, print
true
if the set didn't have that value before, otherwise printfalse
.Picky input, I also overcomplicated this :P
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 facepalmI believe its a newline, about to find out for myself
I way over complicated this and p1...