Oral exam

Report a typo

University students are taking an oral exam at the end of the course.

They get questions simultaneously and have enough time to prepare the answer. Once a student is ready, they put their name on the board in front of the class and wait for their turn to present the answer to the professor.

If the professor likes it, the student gets the grade, removes their name from the board, and leaves the exam.

However, sometimes the professor might want to give the student an additional small task. In this case, they will need to immediately put their name at the end of the current name list on the board and present the solution to the extra question as soon as their turn comes. This can repeat a couple of times before the student finally gets the grade.

Given the log of the exam, print out the names of the students in the order they were leaving the exam.

The number n denotes the total number of records. READY student_name means that the student called student_name is ready to present their answer. PASSED means that the student whose turn it is passed the exam, while EXTRA means that they received an extra question and will have to present again.

Let's look at the example below: the number of records is five. Anna was ready to answer first, and Tom second. But Anna was given an extra question, but Tom was not, so Tom passed the exam first and Anna second. So the output is Tom\nAnna.

Tip: Use split(" ") to split the input string on the whitespace.

Sample Input 1:

5
READY Anna
READY Tom
EXTRA
PASSED
PASSED

Sample Output 1:

Tom
Anna
Write a program in Python 3





___

Create a free account to access the full topic