ТОР 5 статей: Методические подходы к анализу финансового состояния предприятия Проблема периодизации русской литературы ХХ века. Краткая характеристика второй половины ХХ века Характеристика шлифовальных кругов и ее маркировка Служебные части речи. Предлог. Союз. Частицы КАТЕГОРИИ:
|
Problem K. DossiersInput: standard input The following information about all pupils of a school is available: surname, first name, class, date of birth. Depending on situation, Director may need to sort it in different modes. Full list of standard sort modes is: surname — by surname, ignoring first name; fullname — first by surname, then by first name for equal surnames; birthyear — by year of birth, ignoring date inside year, from earlier years (elder pupils) to later years (younger pupils); birthdate — by date of birth, i. e. first by year, then by month, then by day, from earlier dates (elder pupils) to later dates (younger pupils); birthday — by birthdays, from 01.01 to 31.12 (in DD.MM format), considering the same dates of different years equal; grade — by class (1–11) as year of study, ignoring letter; class — first by grade (year of study), then by class letter (A–Z) for equal grades. Sometimes Director needs to use first one of the modes, then another (for pupils equal by first mode), etc. For example, “birthyear grade surname” means to place firstly all pupils who were born in 1998, then all who were born in 1999, etc; pupils, who were born in the same year, should be sorted by grade (class ignoring letter); finally, pupils who were born in the same year and are studying in the same grade should be sorted by surnames. Input The 1st line contains required sort mode, as one or some of words surname, fullname, birthyear, birthdate, birthday, grade, class. At least one word will appear; no word can appear more than once. If there are several words, they are separated by single spaces. The 2nd line contains the quantity of pupils N (2 ≤ N ≤ 12345). The following text contains N four-line groups, describing a pupil. First line of each group contains surname. Surname must begin with capital Latin letter, which can be followed by sequence of Latin letters, hyphens (-) and apostrophes (’). Second line of each group contains first name. First name must begin with capital Latin letter, which can be followed by sequence of Latin letters, hyphens (-), apostrophes (’) and spaces (). Third line of each group contains date of birth, given in format DD.MM.YY, i. e. exactly two digits for day-of-month, point, exactly two digits for month, point, exactly two digits for year. Fourth line of each group contains class — integer number from 1 to 11 and exactly one capital Latin letter, without space between. All dates of birth are correct (for example, it cannot be 30.02) and are in range from 1990 to 2030. It means that, for example, 97 < 02, because 97 means 1997 and 02 means 2002. Typically, pupils of higher classes have earlier dates of birth, but this rule can have exceptions. Major (at least 99.9%) of surnames and first names are not longer than 20 characters, but all we know about the rest 0.1% is that their total length is not greater then one million characters. Surnames and first names may end with Latin letter or apostrophe, and cannot end with hyphen or with space. You should compare surnames with surnames and first names with first names, using standard case-sensitive string comparing, implemented in programming language (even if names contain apostrophes or other non-letter symbols). Output Program should print exactly N lines. Each line should contain information about one pupil, in format: class, comma, surname, comma, first name, comma, date of birth. Each of class, surname, first name and date of birth should be byte-in-byte the same, as in input data. Lines should be sorted according to the specified sort modes. In all cases, when applying of the specified sorting modes to the specified input data leaves the possibility of different correct answers, program should output any one of them. For example, for specified sort modes “birthyear grade surname”, if there are pupils of the same year of birth, studying in the same grade and having the same surname — they can be written in any order, each exactly once.
Не нашли, что искали? Воспользуйтесь поиском:
|