Logo
(追記) (追記ここまで)

11595번 - Classy 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB81493958.209%

문제

In his memoir So, Anyway. . . , comedian John Cleese writes of the class difference between his father (who was “middle-middle-middle-lower-middle class”) and his mother (who was “upper-upperlower-middle class”). These fine distinctions between classes tend to confuse American readers, so you are to write a program to sort a group of people by their classes to show the true distinctions.

There are three main classes: upper, middle, and lower. Obviously, upper class is the highest, and lower class is the lowest. But there can be distinctions within a class, so upper-upper is a higher class than middle-upper, which is higher than lower-upper. However, all of the upper classes (upper-upper, middle-upper, and lower-upper) are higher than any of the middle classes.

Within a class like middle-upper, there can be further distinctions as well, leading to classes like lower-middle-upper-middle-upper. When comparing classes, once you’ve reached the lowest level of detail, you should assume that all further classes are the equivalent to the middle level of the previous level of detail. So upper class and middle-upper class are equivalent, as are middlemiddle-lower-middle and lower-middle.

입력

The first line of input contains n (1 ≤ n ≤ 1,000), the number of names to follow. Each of the following n lines contains the name of a person (a sequence of 1 or more lowercase letters ‘z’–‘z’), a colon, a space, and then the class of the person. The class of the person will include one or more modifiers and then the word class. The colon, modifiers, and the word class will be separated from each other by single spaces. All modifiers are one of upper, middle, or lower. It is guaranteed that the input is well-formed. Additionally, no two people have the same name. Input lines are no longer than 256 characters.

출력

Print the n names, each on a single line, from highest to lowest class. If two people have equivalent classes, they should be listed in alphabetical order by name.

제한

예제 입력 1

5
mom: upper upper lower middle class
dad: middle middle lower middle class
queenelizabeth: upper upper class
chair: lower lower class
unclebob: middle lower middle class

예제 출력 1

queenelizabeth
mom
dad
unclebob
chair

예제 입력 2

10
rich: lower upper class
mona: upper upper class
dave: middle lower class
charles: middle class
tom: middle class
william: lower middle class
carl: lower class
violet: middle class
frank: lower class
mary: upper class

예제 출력 2

mona
mary
rich
charles
tom
violet
william
carl
dave
frank

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2015 Pacific Northwest Region Programming Contest > Division 1 C번

ICPC > Regionals > North America > Rocky Mountain Regional > 2015 Rocky Mountain Regional Contest F번

ICPC > Regionals > North America > Southeast USA Regional > 2015 Southeast USA Regional Programming Contest > Division 2 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /