#C6959. TV Show Recordings Manager
TV Show Recordings Manager
TV Show Recordings Manager
You are given a list of commands to manage a record of TV show recordings. The commands can be of three types:
ADD show_name
: Adds the TV show show_name to the recording list.REMOVE show_name
: Removes the TV show show_name from the recording list if it exists.CHECK show_name
: Checks whether the TV show show_name is currently scheduled for recording. For eachCHECK
command, outputYES
if it exists in the recording list, otherwise outputNO
.
The input is provided via standard input and for each CHECK
command you should output the result on a new line in standard output.
The problem can be mathematically characterized using set operations. For example, if \( S \) denotes the set of recordings, then the commands transform \( S \) as follows:
- \( S = S \cup \{show\_name\} \) for an
ADD
command - \( S = S \setminus \{show\_name\} \) for a
REMOVE
command - Output \( YES \) if \( show\_name \in S \), otherwise output \( NO \) for a
CHECK
command
inputFormat
The first line contains an integer n denoting the number of commands. Each of the following n lines contains a command in one of the following forms:
ADD show_name
REMOVE show_name
CHECK show_name
All commands are processed in the order they appear.
outputFormat
For each CHECK
command encountered, output a single line containing either YES
if the show is in the recording list or NO
otherwise.
7
ADD GameOfThrones
ADD BreakingBad
CHECK GameOfThrones
REMOVE GameOfThrones
CHECK GameOfThrones
ADD TheCrown
CHECK TheCrown
YES
NO
YES
</p>