Retro Racing

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

ChrisT is playing Mario Kart!

At the beginning, when he starts a game he starts at last place, behind N other racers. Given the names of the other racers and who ChrisT passes, he wants to know what place he was and the names of all of the racers that finished the race before him. Because he is too busy grinding Mario Kart races, he would like you to do this for him.

Input Specification

The first line will contain integer N (1 \leq N \leq 10^5), the number of racers in the game with ChrisT.

The next N lines will contain string S, the name of the racer. It is guaranteed that the length of the names will not exceed 20 characters.

Any lines after these will be the racers that ChrisT passes, and will end with finished, meaning that the race has finished. It is guaranteed that these names will exist and the number of races that he passes will be less than or equal to N.

Output Specification

Output one integer, the place that ChrisT is in after passing some amount of racers, and the rest of the racers that were ahead of him, in the order given by the input.

Sample Input 1

5
Dry Bones
Peach
Mario
Bowser
Wario
Bowser
Peach
Mario
finished

Sample Output 1

3
Dry Bones
Wario

Comments

There are no comments at the moment.