## Back to School '16: Paradox

View as PDF

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

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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

• commented on Aug. 24, 2017, 8:30 a.m.

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?

• commented on Aug. 24, 2017, 5:07 p.m. edited

When you attempt to insert a value, print true if the set didn't have that value before, otherwise print false.

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

Picky input, I also overcomplicated this :P

• commented on Sept. 16, 2016, 10:57 p.m. edited

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

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

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

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

I way over complicated this and p1...