seventh的社交网站

TimeLimit:2000MS  MemoryLimit:256MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

图片.png



众所周知,我们seventh自从回家以后异常无聊,于是他就写了一个社交网站,这个网站当然也和别的社交网站一样有添加朋友的功能,但是这个时候seventh想了想,如果社交网站的名字排序按照字典序来,那岂不是太简单了,想到这里,他就设计了一组功能。

·         1. "X posted on Y's wall" (两个人都加15),

·         2. "X commented on Y's post" (两个人加10),

·         3. "X likes Y's post" (两个人5加分).

然后当有人执行了以上操作时,系统就会按照分数加上去,最后,按照得出的分数将名字从大到小排序好(分数一样的按字典序排序), 之后展现在列表里的就是你的好友排序(分数为0也要输出,但是自己的名字不能输出);功能设计好了以后seventh突然不想写了,因为他还是觉得太简单,就交给了你们。


Input

The first line contains your name. The second line contains an integer n, which is the number of actions (1 ≤ n ≤ 100). Then n lines follow, it is guaranteed that each one contains exactly 1 action in the format given above. There is exactly one space between each two words in a line, and there are no extra spaces. All the letters are lowercase. All names in the input will consist of at least 1 letter and at most 10 small Latin letters.


第一行输入你的名字,第二行输入m表示有m个(1<=m<=100)个操作,接下来m行是操作类型,一行中两单词间只有一个空格,只有小写字母,名字最多10个最少1个字符。


Output

Print m lines, where m is the number of distinct names in the input (excluding yourself). Each line should contain just 1 name. The names should be sorted according to the priority factor with you in the descending order (the highest priority factor should come first). If two or more names have the same priority factor, print them in the alphabetical (lexicographical) order.

Note, that you should output all the names that are present in the input data (excluding yourself), even if that person has a zero priority factor.

The lexicographical comparison is performed by the standard "<" operator in modern programming languages. The line a is lexicographically smaller than the line b, if either a is the prefix of b, or if exists such an i (1 ≤ i ≤ min(|a|, |b|)), that ai < bi, and for any j (1 ≤ j < i) aj = bj, where |a| and |b| stand for the lengths of strings a and b correspondently.


输出n行,n行是操作里包含的名字(输出不包括自己的名字),按照优先级一个名字一行输出,第一个优先级最高。


SampleInput 1
ahmed
3
ahmed posted on fatma's wall
fatma commented on ahmed's post
mona likes ahmed's post
SampleOutput 1
fatma
mona
SampleInput 2
aba
1
likes likes posted's post
SampleOutput 2
likes
posted
Submit
题目统计信息详细
总AC数5
通过人数4
尝试人数6
总提交量16
AC率25.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: