编程介的小学生 2017-09-24 07:46 采纳率: 20.3%
浏览 904
已采纳

Charity Begins at Home-page

Dozens of charity WWW sites have appeared recently. These sites donate advertising payments they receive to charitable organizations. But advertisers don't want to pay for people who come to the WWW site dozens of time a day, so require a list of unique visitors to the site. Some sites, such as The Hunger Site (thehungersite.com), the original "Click for Charity" site, allow only one donation per address per day. Others, such as the Meals On Wheels site (givemeals.com), allow donations as frequently as every 6 hours.

You are to write a program to take a list of visits for a month and list the visitors to the site and the number of visits, both valid and invalid, they made in that month.

Input

The input data file contains zero or more records of visitors to a charity WWW site, where each record appears on single line. Each visit will be in the following format:

dd:hh:mm:ss:address

where:

dd is an integer that represents the day of the visit, with 01 <= dd <= 32
hh is an integer that represents the hour of the visit, with 00 <= hh <= 23
mm is an integer that represents the minute of the visit, with 00 <= mm <= 59
ss is an integer that represents the second of the visit, with 00 <= ss <= 59
address is a string that represents the email address of the visitor. The address will consist of the upper and lower case letters, digits, periods ('.'), and the at sign ('@') only. It will have exactly one '@' in it (that will not be the first character) and at least one period after the '@'. The '@' and '.' will not appear next to each other. An address will not end with a '.'. There will be at most 65 characters in the address. Case is not significant in addresses, so a@b.c and A@B.C should be considered to be the same address.

The visits will be arranged in time order, from earliest to latest. While there may be two or more visits at a given time, there will not be two visits for the same address at the same time.

There will be at most 1000 unique addresses in the input file.

The end of input will be indicated by an entry for day 32. This line should not be processed.

Output

Output the number of valid and invalid visits for each address in the file. A visit is valid if it is the first visit in the file for the address or if it is 6 hours or more since the most recent previous valid visit for that address. A visit is invalid if it is not valid (that is, if it is less than 6 hours since the last valid visit for that email address in the file).

Output should be grouped by top-level domain, and within a top-level domain by the second-level domain. The top-level domain of the address is the character or characters after the last period in the address. The second-level domain is the collection of letters and digits immediately before the last period. For example, the address programmer@acm.cs.gcsu.edu has the top-level domain edu and the second-level domain gcsu . Top-level domains should be alphabetized, then the second-level domains alphabetized under them. For each second-level domain, all the donors in that domain should be listed in ASCII order of address, followed by the number of valid donations(right-justified to column 69) and invalid donations(right justified to column 73). There should be one blank line between second-level domains and two blank lines between top-level domains. Use the format in the sample output.

All email addresses in the output should be in lower case.

Sample Input

01:00:24:18:joe@gcsu.edu
01:00:24:18:jane3@cobra.cs.mercer.edu
01:01:00:29:joe@gcsu.edu
01:07:00:29:JOE@GCSU.EDU
01:08:30:15:JANE3@COBRA.CS.MERCER.EDU
01:12:02:19:THOMAS@USA.EDU
02:08:30:15:jane@cobra.cs.mercer.edu
04:07:20:00:bob@ist.ucf.EDU
04:08:18:39:mickey@disney.com
04:13:19:59:bob@ist.ucf.edu
04:18:20:19:thomas@usa.EDU
05:19:19:45:rudy@survivor.cbs.tv
06:00:18:24:jane3@cobra.cs.mercer.edu
06:01:19:45:Rudy@Survivor.CBS.TV
10:00:24:18:joe@gcsu.edu
32:01:02:03:last.name@the.list

Sample Output

TOP-LEVEL DOMAIN = com
Second level domain = disney
mickey@disney.com 1 0

TOP-LEVEL DOMAIN = edu
Second level domain = gcsu
joe@gcsu.edu 3 1

Second level domain = mercer
jane3@cobra.cs.mercer.edu 3 0
jane@cobra.cs.mercer.edu 1 0

Second level domain = ucf
bob@ist.ucf.edu 1 1

Second level domain = usa
thomas@usa.edu 2 0

TOP-LEVEL DOMAIN = tv
Second level domain = cbs
rudy@survivor.cbs.tv 2 0

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-11 10:39
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错