#C2557. Movie Rental System

    ID: 45886 Type: Default 1000ms 256MiB

Movie Rental System

Movie Rental System

You are required to implement a movie rental system that supports three operations: ADD, RENT, and HISTORY.

The operations are described as follows:
- ADD userId movieId: Add a movie with identifier movieId to the cart of the user identified by userId.
- RENT userId: Rent all movies currently in the user's cart. This operation clears the cart and appends the movies to the user's rental history.
- HISTORY userId: Print the rental history for the user in the order the movies were rented. If no movies have been rented for that user, print -1.

For instance, after executing ADD 1 101 and ADD 1 102 for user 1, a HISTORY 1 operation will initially output -1 because the movies have not been rented yet. Once RENT 1 is executed, a subsequent HISTORY 1 will output 101 102.

Remember that if you need to include any formulas, use (\LaTeX) format (e.g., (a^2+b^2=c^2)).

inputFormat

The first line contains an integer (Q), the number of operations. Each of the following (Q) lines contains an operation in one of the following formats:

- ADD userId movieId
- RENT userId
- HISTORY userId

It is guaranteed that userId and movieId are integers.

outputFormat

For every HISTORY operation in the input, output a single line containing the movie IDs of the rented movies separated by a space, in the order they were rented. If the rental history is empty for that user, output -1.## sample

6
ADD 1 101
ADD 1 102
HISTORY 1
RENT 1
HISTORY 1
HISTORY 2
-1

101 102 -1

</p>