HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Sorting and sequences > problem:


50915 - Trip to Korca

Guest
• Review clarifications (3)

Section problems

• 50875 - Take m-out
• 50748 - Gold Store
• 50766 - Word Puzzle
• 50741 - DNA Distance
• 50934 - Selling Cars
• 50746 - Most Visited
• 50509 - Reading Book
• 50749 - Min Distance
• 50915 - Trip to Korca
• 50802 - Comparing Exams
• 50927 - Health Expenses
• 50745 - Bitonic Sequence
• 50992 - Top K Obese Classes
• 50991 - Intersecting Circles
• 50447 - Swimming Contest - 2
• 50513 - Climbing Up the Stairs
• 50744 - The Smallest Perimeter

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Trip to Korca

Question: TraveLovers club is organizing a trip to Korca. You have the full students list. Then, you will be given m student IDs who are participating to the trip. Show sorted list of participating students according to department codes. If there are several students from the same department, show students according to grade attending (and name, then surname) in ascending order.

Input specification
You will be given two integers in the beginning: the number of students (n) and the number students (m) who are participating to the activity. Then, in the following n lines you will be given n student information which is sorted according to IDs:

  • Student ID: an integer not greater than 500,000
  • Name and surname: at most 15 chars strings (separated by a space)
  • Department code: at most 5 chars string (some possible codes are CEN, ECE, BINF, etc.)
  • Grade attending: integer between 1 and 5 where 1 means first grade (year) student, etc.
where 0 ≤ m ≤ n ≤ 40,000.

Output specification:
Show department, grade, name and surname of the students who are participating.

Sample Input I
10 5
4 Dominic Allison BINF 1
7 Moses Mendez CEN 4
9 Alison Burns CEN 3
13 Marilyn Patterson ECE 3
18 Jean Bass BINF 4
20 Cora Duncan ECE 3
24 Marta Roberson BINF 3
25 Jill Flores ECE 1
28 Carla Holmes CEN 2
32 Mike Johnston ECE 1
20 7 32 13 9
Sample Output I
CEN 3 Alison Burns
CEN 4 Moses Mendez
ECE 1 Mike Johnston
ECE 3 Cora Duncan
ECE 3 Marilyn Patterson



Для отправки решений необходимо выполнить вход.

www.contester.ru