eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Heavy Chain Clusterization

Heavy Chain Clusterization

Группа биологов пытается найти лекарство от вирусного заболевания. Они испробовали много антител различного происхождения, которые потенциально могут побороть вирусные антигены, и выбрали п антител, которые по их мнению работают лучше в ходе экспериментов.

Каждое антитело идентифицируется своей тяжелой цепью - последовательностью аминокислот.

The set of antibodies form a similarity cluster, if at least one of the following holds:

  • k-prefixes (first k amino acids) of all their heavy chains are equal;
  • k-suffixes (last k amino acids) of all their heavy chains are equal.

In order to simplify the future research, biologists want to group antibodies to similarity clusters.

You need to split the given antibodies to a minimum number of similarity clusters.

Входные данные

The first line contains two integers n and k - the number of heavy chains and the length of sequence of amino acids to coincide (1n5000, 1k550).

The following n lines contain sequences of amino acids that form heavy chains of antibodies. Each amino acid described with an uppercase English letter. Each heavy chain contains at least k and no more than 550 amino acids.

Выходные данные

The first line must contain a single integer - the minimum number of similarity clusters.

The following lines must contain descriptions of clusters, one per line.

Each description starts with mi - the number of antibodies in the cluster and is followed by mi integers - numbers of these antibodies. Antibodies are numbered in the order of appearance in the input starting from one.

Each antibody must be present in exactly one cluster.

Лимит времени 2 секунды
Лимит использования памяти 256 MiB
Входные данные #1
4 1
AA
AB
BB
BA
Выходные данные #1
2
2 1 2
2 3 4
Входные данные #2
3 2
ABA
BAB
XY
Выходные данные #2
3
1 1
1 2
1 3
Источник 2013 ACM NEERC, Northern Subregional Contest, St Petersburg, October 26