All Tracks Problem

Annual Function
Tag(s):

Medium, 普通

Problem
Editorial
Analytics

There is an Annual function in the College and each event's participants will have a parade in the Opening Ceremony of the function.

Participants belonging to one event will form one queue according to the lexicographically sorted order of their names. It means the participant whose name comes first in the lexicographically sorted list of the names belonging to the same event, will comes first in the queue.

The Chairman of the College wants to give advices to the first two and the last two participant's of each event's queue in order to have a good parade.

Given the details of the events, i.e event name and the name of the participant belonging to that event, you need to extract the first two and last two participants belonging to each event when sorted lexicographically.

Note:
1) The given data contains some NULL values as Student Name. If the Student Name is NULL, then replace it with 'M.James' and then perform the required operation.
2) Check Sample I/O for more clarity. The extracted data should be in the same format as of sample output.

Input Format

Table : Events

Field Type
Event_Name text
Student_Name text

Sample Explanation

Sample Events table:

Event_Name Student_Name
Quiz Joe
Quiz Jack
Quiz NULL
Quiz Anany
Sqlizer Aakay
Sqlizer Micro
Sqlizer Macro
Sqlizer Praky

Output

Event_Name First_Two Last_Two
Quiz Anany,Jack Joe,M.James
Sqlizer Aakay,Macro Micro,Praky
Time Limit: 5 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: MySQL, PostgreSQL, MSSQL, Oracle Database

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications