QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100 Difficulty: [show]

#15. 虫逢

統計

小强和阿米巴是好朋友。

阿米巴告诉小强,变形虫(又叫阿米巴虫)和绝大多数生物一样,也是有 DNA 的。并且,变形虫可以通过分裂的方式进行无性繁殖。

我们把一个变形虫的基因组抽象成一个大小为 $L$ 的基因集合。每个基因都是一个 $4$ 位长的字符串(字符包括大小写字母、数字、符号“~!@#$%^&()[]`:;"'<>,.?/|\=-{}”)。现在,有 $N$ 个变形虫凑到了一起。由于他们是从天南海北过来的,我们可以认为,他们的基因组都是从一个大小为 $M$ 的“变形虫基因库“中独立的随机的选取L个基因得到的。目前人类并不了解这个基因库里都有什么基因,但是我们知道它的大小是 $M$。

这时,环境突然发生巨变。这 $N$ 个变形虫在外界的刺激下同时进行了一次分裂。每个变形虫分裂成了两个。分裂的过程中,原来的变形虫的基因组(基因的集合)被原样的复制成了两份,分别进入两个新的变形虫。两个新变形虫中的一只的基因组中有一半发生了突变,被替换为“变形虫基因库”中随机的其他的基因。如果两个变形虫是由原来的一个变形虫产生的,我们叫它们“同源”的。

给出 $2N$ 个变形虫的基因组,请你找出每个变形虫同源的另一只虫是谁。

输入格式

第一行三个整数 $N$、$M$、$L$。

接下来一行 $2NL \times 4$个字符,依次表示每个集合中的元素。集合内的元素之间的顺序是无关紧要的。

输出格式

输出 $2N$ 行,每行一个整数表示第 $i$ 个变形虫(从 $1$ 开始标号)同源的另一只变形虫是谁。

样例一

input

2 100 6
H[P,86(^,<n&7X_Sg"LY67m2H$n+5'!VHp5IA.@GM:4-NJsqsiG!H[P,7X_S86(^>aNQ22'B5'!V<FD!F!6xNJsq>!]dHp5I

output

3
4
1
2

样例二

见样例数据下载

explanation

输入文件一共有两行。四个基因组分别是

H[P,”,“86(^”,“,<n&”,“7X_S”,“g"LY”, “67m2

H$n+”,“5'!V”,“Hp5I”,“A.@G”,“M:4-”,“NJsq

siG!”,“H[P,”,“7X_S”,“86(^”,“>aNQ”,“22'B

5'!V”,“<FD!”,“F!6x”,“NJsq”,“>!]d”,“Hp5I

明显,1、3是同源的,2、4是同源的。

限制与约定

一共有 $10$ 个测试点。数据均为按照题目中描述的方法随机生成的。对于非同源的两个变形虫,他们的基因组的交的大小均小于 $L/2$。对于同源的两个变形虫,他们的基因组的交的大小刚好是 $L/2$。

测试点编号 $N$ $M$ $L$
1$400$$400$$20$
2$900$$900$$30$
3$1600$$1600$$40$
4$2500$$2500$$50$
5$3600$$3600$$60$
6$6400$$6400$$80$
7$10000$$10000$$100$
8$12100$$12100$$110$
9$14400$$14400$$120$
10$16900$$16900$$130$

最大的一个测试数据的大小是 $17\texttt{MB}$ 左右($2NL \times 4=17576000$)。在测评系统上,由于磁盘缓存的存在,使用 scanf 将数据读入需要的时间小于 $0.1$ 秒。请不要使用 cin。经测试:

  • 一个实现良好的 $O(N^2L)$时间复杂度的算法能拿 30 分,
  • 一个实现良好的 $O(N^2 + N^2L^2 / M)$时间复杂度的算法能拿 50 分。
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.