#K11406. Guest List Manager

    ID: 23461 Type: Default 1000ms 256MiB

Guest List Manager

Guest List Manager

You are organizing a movie night and need to manage the guest list. Each guest can send a command to accept, decline, or cancel their RSVP.

The program receives commands in the following format:

  • ACCEPT <name>: The guest with the specified name accepts the invitation.
  • DECLINE <name>: The guest declines the invitation.
  • CANCEL <name>: The guest cancels an earlier acceptance.

Note that if a guest sends multiple commands, only the final state is considered. For example, if a guest first accepts and then declines, they will not be counted as attending.

The task is to compute the final count of accepted guests.

The operation can be summarized by the following logic:

$$\text{For each command, update the set of accepted guests accordingly.}$$

inputFormat

The input is provided via standard input (stdin). The first line contains an integer n, representing the number of commands. This is followed by n lines, each containing a command in one of the following formats:

ACCEPT DECLINE CANCEL

Each command consists of an action and a guest name separated by a space.

outputFormat

Output a single integer to standard output (stdout), which represents the number of guests whose final status is accepted.## sample

7
ACCEPT Alice
ACCEPT Bob
DECLINE Alice
CANCEL Bob
ACCEPT Charlie
ACCEPT Alice
CANCEL Charlie
1