CF63A.Sinking Ship

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically:

The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last.

If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less).

For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew.

飞船撞上了礁石,正在下沉。现在全体船员必须立即撤离。所有 nn 名船员已排成一列(为方便起见,我们从左到右依次用正整数 11 到 nn 为其编号),等待进一步指令。然而,船员的撤离必须严格遵循既定顺序。具体规则如下:

首先撤离的是老鼠(rats);
接着是妇女(women)和儿童(children)——这两类人员具有相同的优先级;
然后是所有男性(men)撤离;
最后,船长(captain)离开正在下沉的船。

若根据上述规则仍无法确定任意两名船员中谁应先撤离,则位置靠左者(即编号较小者)先撤离。

对于每名船员,我们已知其身份(status)及其姓名(name)。所有船员的姓名互不相同。请确定船员的撤离顺序。

输入格式

The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain.

第一行包含一个整数 nn,表示船员人数(1≤n≤1001 \leq n \leq 100)。接下来有 nn 行。其中第 ii 行包含两个单词——排在队列中第 ii 位的船员姓名及其在船上的身份。这两个单词之间恰好由一个空格分隔,行中无其他空格。姓名由拉丁字母组成,首字母大写,其余字母小写;每个姓名长度为 11 至 1010 个字符。身份取值如下:rat 表示老鼠,woman 表示女性,child 表示儿童,man 表示男性,captain 表示船长。船员中恰好有一名船长。

输出格式

Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship.

输出 n 行。其中第 i 行应包含必须第 i 个离开飞船的船员姓名。

输入输出样例

  • 输入#1

    6
    Jack captain
    Alice woman
    Charlie man
    Teddy rat
    Bob child
    Julia woman

    输出#1

    Teddy
    Alice
    Bob
    Julia
    Charlie
    Jack

输入解题思路,AI测评打分。不知道怎么写?

首页