Back To School '16: Paradox

View as PDF

Submit solution

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 C 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).

E will be either true or false.

Input Specification

1 \le C \le 100

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


  • 0
    Ish_God  commented on Aug. 24, 2017, 12:30 p.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?


    • 2
      Paradox  commented on Aug. 24, 2017, 9: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.


  • -2
    ThePenguinCo  commented on Sept. 18, 2016, 2:26 a.m.

    Picky input, I also overcomplicated this :P


  • -1
    paydayzcool  commented on Sept. 17, 2016, 2:57 a.m. edit 2

    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


    • -2
      println_hi_  commented on Oct. 15, 2016, 5:30 p.m.

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


  • 2
    jlsajfj  commented on Sept. 16, 2016, 10:14 p.m.

    I way over complicated this and p1...