#K42862. Registration System

    ID: 27182 Type: Default 1000ms 256MiB

Registration System

Registration System

You are tasked with designing a registration system for managing event attendees.

The system supports the following operations:

  • register: Registers a new attendee by assigning a unique incremental ID starting from 1 and prints the new ID.
  • cancel k: Cancels the registration of the attendee with ID k. This operation does not produce an output.
  • check k: Checks whether the attendee with ID k is currently registered. It prints True if active and False otherwise.
  • retrieve: Retrieves and prints the list of active registration IDs in ascending order. The IDs should be printed on one line separated by a single space.

Formally, implement a class RegistrationSystem with the following methods: $$ \begin{aligned} register()& : \text{Assign a new attendee ID and return it.}\\ cancel(k)& : \text{Mark the registration with ID } k \text{ as cancelled.}\\ check(k)& : \text{Return whether the registration with ID } k \text{ is active.}\\ retrieve()& : \text{Return the list of active IDs in ascending order.} \end{aligned} $$ The behavior of the commands is demonstrated in the sample test cases below.

inputFormat

The input is read from standard input. The first line contains an integer N, the number of commands.

Each of the following N lines contains a command. The commands can be one of the following formats:

  • register — Register a new attendee. No additional argument.
  • cancel k — Cancel the registration with ID k, where k is an integer.
  • check k — Check if the attendee with ID k is active.
  • retrieve — Retrieve the list of active attendee IDs.

outputFormat

The output is written to standard output. For each command:

  • register: Print the new attendee ID on a separate line.
  • cancel: Do not print anything.
  • check: Print True or False on a separate line.
  • retrieve: Print the active IDs in ascending order on one line, separated by a single space. If no IDs are active, print an empty line.
## sample
4
register
register
check 1
check 2
1

2 True True

</p>