CROC 2016 - Qualification
C
Hostname Aliases
Codeforces
2100
原题
← B→
翻译中…

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://<hostname>[/<path>], where:

翻译中…
  • <hostname> — server name (consists of words and maybe some dots separating them),
  • /<path> — optional part, where consists of words separated by slashes.
翻译中…

We consider two <hostname> to correspond to one website if for each query to the first <hostname> there will be exactly the same query to the second one and vice versa — for each query to the second <hostname> there will be the same query to the first one. Take a look at the samples for further clarifications.

翻译中…

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://<hostname> and http://<hostname>/ are different.

翻译中…

Input

翻译中…

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://<hostname>[/<path>], where:

翻译中…
  • <hostname> consists of lowercase English letters and dots, there are no two consecutive dots, <hostname> doesn't start or finish with a dot. The length of <hostname> is positive and doesn't exceed $20$.
  • <path> consists of lowercase English letters, dots and slashes. There are no two consecutive slashes, <path> doesn't start with a slash and its length doesn't exceed $20$.
翻译中…

Addresses are not guaranteed to be distinct.

翻译中…

Output

翻译中…

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.

翻译中…

样例

Input #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
Output #1
1
http://abacaba.de http://abacaba.ru
InputCopy OutputCopy
Input #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
Output #2
2
http://cba.com http://ccc.bbbb
http://a.a.a http://a.c http://abc
InputCopy OutputCopy
题目信息
题号
644C
时间限制
5 s
内存限制
256 MB
标签
*special
二分
数据结构
模拟
排序
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。