시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB27242187.500%

문제

CS@Mines is restocking on supplies and is looking to make an inventory management system for a warehouse which keeps those supplies.

Due to our warehouse constraints, we can only keep one item in any given location at a time! Therefore, we need to manage when items are taken and put into the warehouse inventory. Additionally, we only have at most $10$ copies of each item.

Additionally, professors and students are actively using the warehouse! While we are still unloading shipments, items may be taken out of the warehouse before more come in. There are three distinct events which can occur in the warehouse:

An item can be PUT into a specific location.

Someone can TAKE the item currently in the specified location, which removes it from the location.

Someone can FIND all of the locations that contain the specified item. Note that since there at most 10 copies of each item, this should return at most 10 locations.

입력

The first line of input will be an integer $1 \leq N \leq 10^5$ representing how many lines of input are to follow.

The next $N$ lines will each consist of one of the following operations:

A PUT operation, in the following format: PUT [ITEM] [LOCATION].

A TAKE operation, in the following format: TAKE [LOCATION]. There will never be a TAKE operation for a location that does not currently have an item.

A FIND operation, in the following format: FIND [ITEM] indicating that someone wants to look up the locations of a specific item.

All LOCATIONs and ITEMs will be strings of uppercase Latin letters (A-Z) of length at most $10$.

출력

For each FIND operation, output the location(s) which contain the ITEM specified by the FIND as a lexicographically sorted, space-separated list. Or, if the item cannot be found, print out: "NOT FOUND" (without the quotes).

The output of each FIND operation is based off previously seen operations; in other words, the PUT and TAKE operations are done in chronological order.

예제 입력 1

3
PUT COMPUTER UPSTAIRS
PUT COMPUTER DOWNSTAIRS
FIND COMPUTER

예제 출력 1

DOWNSTAIRS UPSTAIRS

예제 입력 2

4
PUT COMPUTER LECTUREHAL
TAKE LECTUREHAL
PUT COMPUTER CLOSET
FIND COMPUTER

예제 출력 2

CLOSET

예제 입력 3

11
PUT PENCIL A
PUT PAPER B
PUT LAPTOP C
TAKE B
PUT LAPTOP D
PUT LAPTOP E
TAKE E
PUT PEN F
TAKE A
FIND LAPTOP
FIND PAPER

예제 출력 3

C D
NOT FOUND

예제 입력 4

22
PUT DONUTS A
PUT COFFEE B
PUT TOAST C
PUT KETTLE D
PUT DONUTS E
PUT MUG F
PUT MICROWAVE G
PUT MUG H
PUT MILK I
PUT COFFEE J
FIND DONUTS
TAKE A
TAKE B
TAKE C
TAKE D
TAKE E
TAKE F
FIND MUG
TAKE G
TAKE I
TAKE J
FIND MICROWAVE

예제 출력 4

A E
H
NOT FOUND

출처

School > CS@Mines > CS@Mines HSPC 2024 H번

  • 문제를 만든 사람: Ethan Richards