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)

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

Input Specification

1 \le C \le 100

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, 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?


    • 1
      Paradox  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.


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

    Picky input, I also overcomplicated this :P


  • 0
    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


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

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


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

    I way over complicated this and p1...