QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#15055. 病毒分类

Statistics

故事背景

JSOI爆发一种罕见的懒惰拖延症,为了拯救小伙伴们于水生火热之中,JYY 收集了 JSOI王国中所有病毒的DNA序列,并希望对这些DNA序列进行分类,以便深入分析来找出治疗拖延症的方法。

问题描述

JSOI王国里一共有 $N$ 种不同的病毒,每种病毒的 DNA 序列都由一个大写字母序列来表示。

JYY希望将这些病毒分成尽量少的类别,使得每个病毒都属于且仅属于某一个类别。

分入同一个类别的病毒需要满足如下两条性质中的至少一条

  1. 所有同类病毒DNA序列的“$k$ 前缀”(前 $k$ 个大写字母)都相同;
  2. 所有同类病毒DNA序列的“$k$ 后缀”(后 $k$ 个大写字母)都相同。

JYY希望找出一种分类方案,使得所分成的类别满足要求并且类别总数最小。

输入格式

第一行包含两个正整数 $N$ 和 $k$。

接下来 $N$ 行,第 $i$ 行包含一个字符串 $S_i$,表示编号为 $i$ 的病毒的 DNA 序列。数据保证 $S_i$ 的长度不小于 $k$。

输出格式

第一行包含一个整数 $C$,表示最少的类别的数量。

接下来 $C$ 行,每一行首先为一个正整数 $w$,表示当前类别中的病毒数量,接下来 $w$ 个正整数,表示属于当前类别的病毒的编号。

如果有多个最佳方案,输出任意一组即可。

评分方式

对于每一个测试点,如果第一行包含正确的正整数 $C$,则可以得到 5 分。

如果在第一行正确的前提下,接下来 $C$ 行描述了一个合法的最佳方案,则可以得到 10 分。

其余情况得 0 分。

样例数据

样例输入

4 1
A
AB
BB
BA

样例输出

2
2 1 2
2 3 4

样例说明

样例输出可以得到 10 分。

数据规模与约定

对于 $20\%$ 的数据满足 $N \le 10$

对于 $40\%$ 的数据满足 $N \le 500$

对于 $100\%$ 的数据满足 $N \le 5\,000$, $k \le 550$

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.