CF644C.Hostname Aliases
提高+/省选-
通过率:0%
时间限制:5.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are some websites that are accessible through several different addresses. For example, for a long time Codeforces was accessible with two hostnames codeforces.com and codeforces.ru.
You are given a list of page addresses being queried. For simplicity we consider all addresses to have the form http://
— server name (consists of words and maybe some dots separating them), - /
— optional part, where consists of words separated by slashes.
We consider two
Your goal is to determine the groups of server names that correspond to one website. Ignore groups consisting of the only server name.
Please note, that according to the above definition queries http://
有些网站可以通过多个不同的地址访问。例如,Codeforces 长期以来可通过两个主机名 codeforces.com 和 codeforces.ru 访问。
你将获得一份被查询的网页地址列表。为简化起见,我们假设所有地址均具有形式 http://<hostname>\[/<path>\],其中:
<hostname>—— 服务器名称(由若干单词组成,单词之间可能用若干个点号.分隔);/<path>—— 可选部分,其中<path>由斜杠/分隔的若干单词构成。
我们认为两个 <hostname> 对应于同一个网站,当且仅当:对第一个 <hostname> 的每个查询,都存在一个完全相同的、针对第二个 <hostname> 的查询;反之亦然:对第二个 <hostname> 的每个查询,也都存在一个完全相同的、针对第一个 <hostname> 的查询。请参阅样例以进一步明确该定义。
你的目标是找出所有对应于同一网站的服务器名称分组。请忽略仅包含一个服务器名称的分组。
请注意,根据上述定义,查询 http://<hostname> 与 http://<hostname>/ 被视为不同。
输入格式
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of page queries. Then follow n lines each containing exactly one address. Each address is of the form http://
consists of lowercase English letters and dots, there are no two consecutive dots, doesn't start or finish with a dot. The length of is positive and doesn't exceed 20. consists of lowercase English letters, dots and slashes. There are no two consecutive slashes, doesn't start with a slash and its length doesn't exceed 20.
Addresses are not guaranteed to be distinct.
输入的第一行包含一个整数 n(1 ≤ n ≤ 100000),表示页面查询的次数。接下来有 n 行,每行恰好包含一个网址。每个网址的形式为 http://<hostname>[/<path>],其中:
<hostname>由小写英文字母和点号(.)组成,不含两个连续的点号,且不以点号开头或结尾;<hostname>的长度为正整数,且不超过 20。<path>由小写英文字母、点号(.)和斜杠(/)组成,不含两个连续的斜杠,且不以斜杠开头;<path>的长度不超过 20。
这些网址不一定互不相同。
输出格式
First print k — the number of groups of server names that correspond to one website. You should count only groups of size greater than one.
Next k lines should contain the description of groups, one group per line. For each group print all server names separated by a single space. You are allowed to print both groups and names inside any group in arbitrary order.
首先输出 k —— 对应同一网站的服务器名称组的数量。你只需统计大小大于一的组。
接下来的 k 行应描述这些组,每行描述一个组。对每个组,输出该组中的所有服务器名称,各名称之间用一个空格分隔。你可以以任意顺序输出各组,也可以在每组内以任意顺序输出服务器名称。
输入输出样例
输入#1
10 http://abacaba.ru/test http://abacaba.ru/ http://abacaba.com http://abacaba.com/test http://abacaba.de/ http://abacaba.ru/test http://abacaba.de/test http://abacaba.com/ http://abacaba.com/t http://abacaba.com/test
输出#1
1 http://abacaba.de http://abacaba.ru
输入#2
14 http://c http://ccc.bbbb/aba..b http://cba.com http://a.c/aba..b/a http://abc/ http://a.c/ http://ccc.bbbb http://ab.ac.bc.aa/ http://a.a.a/ http://ccc.bbbb/ http://cba.com/ http://cba.com/aba..b http://a.a.a/aba..b/a http://abc/aba..b/a
输出#2
2 http://cba.com http://ccc.bbbb http://a.a.a http://a.c http://abc
输入解题思路,AI测评打分。不知道怎么写?