ZOJ Problem Set - 1747
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 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 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 = mercer firstname.lastname@example.org 3 0 email@example.com 1 0 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
Source: Southeast USA 2000