StripeOA #13
Email Log Processing, Grouping, and Sorting
估计中等可在线判题
Given an email event log, group the events by sender. Sender groups are sorted lexicographically; within each group, events are sorted by timestamp in ascending order, then by recipient and subject in ascending lexicographic order. A subject may contain spaces and may also be empty.
输入格式
The first line contains n (1..200000), followed by n lines: a non-negative integer timestamp, sender, recipient, and subject. The sender and recipient contain no whitespace; the subject is the raw text from the 4th field of the line to the end of the line. Each line has at most 300 characters.
输出格式
First output the number of result lines; then, following the rules, output sender: <sender>, followed by that group's <timestamp> <recipient> [subject] lines. When the subject is empty, do not output an extra space.
样例 1
输入:
5
100 alice@a.com bob@b.com hello
90 alice@a.com carl@c.com meeting notes
90 dan@d.com e@e.com hi
90 alice@a.com bob@b.com a-subject
100 dan@d.com a@a.com ping
输出:
7
sender: alice@a.com
90 bob@b.com a-subject
90 carl@c.com meeting notes
100 bob@b.com hello
sender: dan@d.com
90 e@e.com hi
100 a@a.com ping
样例 2
输入:
1
0 a@a.com b@b.com hi
输出:
2
sender: a@a.com
0 b@b.com hi
样例 3
输入:
3
7 z@e.com b@e.com same
7 z@e.com a@e.com same
7 a@e.com z@e.com
输出:
5
sender: a@e.com
7 z@e.com
sender: z@e.com
7 a@e.com same
7 b@e.com same