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.
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 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 firstname.lastname@example.org 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 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 email@example.com 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.
TOP-LEVEL DOMAIN = com
Second level domain = disney
firstname.lastname@example.org 1 0
TOP-LEVEL DOMAIN = edu
Second level domain = gcsu
email@example.com 3 1
Second level domain = ucf
firstname.lastname@example.org 1 1
Second level domain = usa
email@example.com 2 0
TOP-LEVEL DOMAIN = tv
Second level domain = cbs
firstname.lastname@example.org 2 0
- 点赞 评论 复制链接分享
http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece763104586374e16c6346ac0d0622e89cc5f93130a1d5a2ebee324271601ced1393a41f94606b9b46d2e621420c6db8fd45ddccbc47567df7b75671cf71c46c419de9a1c76817bd611feaf68a2ffb52593df9388990312dd537420d3b4dc4d0065992db24362a3f1cf5f152e50edbc6739b9073c3e9e5357b630&p=ce6dd60f85cc43bc2abd9b7e0a43&newp=b43bc64ad4df5fff57ed93267f5692695803ed603ad0d601298ffe0cc4241a1a1a3aecbf2121170fd2c57a6601a44857eaf034793c0234f1f689df08d2ecce7e3396&user=baidu&fm=sc&query=Having+runDozens+of+charity+WWW+sites+have+appeared+recently%2E&qid=d9980d3500008124&p1=2点赞 评论 复制链接分享