QOJ.ac

QOJ

実行時間制限: 3.0 s メモリ制限: 512 MB 満点: 100

#12710. 加入对话

統計

Abstract Communication Mastership (ACM) 是一家开发了名为 tWinter 的独特社交网络的软件公司。

每个 tWinter 用户都有一个以“at”符号(‘@’)开头的用户名(handle)。tWinter 社交网络的用户向网络发布短消息。

如果一条消息包含另一个用户的用户名(前面有空格或位于消息开头,后面有空格或位于消息结尾),则称之为一次提及(mention)。

如果一个消息序列中,除第一条消息外的每一条消息都包含前一条消息作者的用户名,则称该序列为一次对话(conversation)。

你需要从给定的按时间顺序排列的消息日志中找到最长的对话。

输入格式

输入文件的第一行包含一个整数 $n$ ($1 \le n \le 50\,000$),表示按时间顺序排列的消息数量。

接下来的 $n$ 行,每行包含一条消息,消息前依次是作者的用户名、一个冒号(‘:’)字符和一个空格。

每条消息最多 139 个字符长。每个用户名最多 20 个字符长,且不包含冒号或空格。

输入文件仅包含 ASCII 码在 32 到 126 之间的字符以及换行符。

输出格式

在输出文件的第一行,写入给定日志中最长对话的长度。在第二行,按升序写入该对话中消息的 1-based 索引。

如果存在多个最长对话,输出其中任意一个即可。

样例

输入格式 1

6
@Petr: Leaving for #NEERC tomorrow!
@Roman: This #NEERC is going to be awesome!
@Stone_in_forest: Nothing happened today.
@NEERCNews: @Petr Don’t forget an umbrella :)
@Lydia: @NEERCNews cares about @Petr - so cute ^_^
@Lydia: @Lydia @NEERCNews @Petr it won’t be raining though!

输出格式 1

3
1 4 5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.