3757. 沈航和她的动物朋友们


SAU with animal friends

time limit per test:1s

memory limit per test:256MB


Description:

SAU has many animal friends, and recently there have been many more. The school animal breeder wants to create an information retrieval table about animals. Can you help him?

Provide information on animals in the input data, such as group(mammal/bird), species (six species including deer, rabbit, alpaca, swan, goose, and peacock), name, age, and friendliness. You need to count the number of each animal and sort them by age or friendliness by category.


Input Format:

First line input  to indicate how many animals there are.


The second to  lines input information about the animal's group, species, name, age, friendliness, with spaces separating each item.


On line , enter  and , separated by a space.

  • op of 1 represents ascending sorting of mammal categories by age

  • op of 2 represents ascending sorting of bird categories by age

  • op of 3 represents ascending sorting of mammal categories by friendliness

  • op of 4 represents ascending sorting of bird categories by friendliness.


If two animals have the same age or friendliness during the sorting process, sort their names according to string sorting rules. represents the name of the k-th animal in the sorted table.



Output Format:

The first line outputs the number of each animal in the order of deer, rabbit, alpaca, swan, goose, Peacock, separated by a space.


The second line outputs the name of the animal obtained.


Input Case:

5
mammal deer hu 2 6
mammal alpaca zhang 2 8
bird swan yang 3 9
bird goose ye 4 5
mammal rabbit ji 1 7
1 2


Output Case:

1 1 1 1 1 0
hu


Tips:

Comparison rules for strings

Starting from the first character, compare them one by one according to the size of the ASCII code value. If encountering unequal characters, stop the comparison of subsequent characters and return the comparison results according to the size relationship of the characters; If the length is equal and each character is equal, then it is equal; If the previous part is equal, a longer string will be larger.


沈航和她的动物朋友们

时间限制:1s

内存限制:256MB


题目描述

沈航里有好多动物朋友,最近又多了好多。学校的动物饲养员想要做一个关于动物的信息检索表,你可以帮帮他吗?

输入数据中提供动物的信息,如大类(mammal\bird)、种类(deerrabbitalpacaswangoosepeacock 共 6 种)、名字、年龄与友善度。你需要统计每种动物的数目并将动物按大类归类按年龄或友善度进行排序。


输入格式

第一行输入 ,表示有多少动物。 第二至  行输入动物的大类、种类、名字、年龄、友善度等信息,每项之间有空格隔开。 第  行输入  与 ,中间有空格隔开。

  • op 为 1 代表对mammal大类按年龄进行升序排序

  • op 为 2 代表对bird大类按年龄进行升序排序

  • op 为 3 代表对mammal大类按友善度进行升序排序

  • op 为 4 代表对bird大类按友善度进行升序排序。

排序过程中若两动物年龄或友善度相等,则按照字符串排序规则对动物名字进行排序。 代表要排序好的表中第  个动物的姓名。


名字长度;

年龄;

友善度


输出格式

第一行按照deerrabbitalpacaswangoosepeacock的顺序输出每种动物的数量,中间用空格隔开。

第二行输出求得的动物的名字。


输入样例

5
mammal deer hu 2 6
mammal alpaca zhang 2 8
bird swan yang 3 9
bird goose ye 4 5
mammal rabbit ji 1 7
1 2


输出样例

1 1 1 1 1 0
hu


补充

字符串的比较规则从第一个字符按ASCII码值大小开始逐个比较,若遇到不等的字符则停止后续字符的比较,并按该字符大小关系返回比较结果;若长度相等且每个字符均相等则相等;若前一部分相等则长度更长的字符串更大。

难度等级: 0
总通过次数: 25
总提交次数: 183