#C8445. Taco Array Operations

    ID: 52428 Type: Default 1000ms 256MiB

Taco Array Operations

Taco Array Operations

In this problem, you must simulate a series of operations on an array. There are three types of operations:

1. Insert Operation: Represented as "1 x", where x is an integer. This operation appends the integer x to the end of the array.

2. Delete Operation: Represented as "2". This removes the last element from the array if it exists; if the array is empty, nothing happens.

3. Retrieve Operation: Represented as "3 y", where y is a 0-indexed integer. This operation retrieves the y-th element of the array. If the index y is not valid (i.e. when y is out of the current bounds of the array), you must output an error message: Cannot retrieve from an empty array.

The task is to perform the given operations in order and print the result for each retrieve operation. Note that the array is initially empty.

inputFormat

The input is read from standard input (stdin).

The first line contains a single integer T, representing the number of operations. Each of the following T lines contains an operation in one of the following formats:

- "1 x" : Insert operation, where x is an integer to be appended to the array.
- "2" : Delete operation, which removes the last element from the array if it exists.
- "3 y" : Retrieve operation, where y is a 0-indexed integer. If y is not a valid index, print the error message.

outputFormat

For every retrieve operation (command starting with "3"), print the corresponding result on a new line. If the retrieval operation is invalid due to an out-of-bounds index, print the exact message: Cannot retrieve from an empty array.## sample

4
1 5
1 10
3 0
3 1
5

10

</p>