QOJ.ac

QOJ

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

#22440. DNA 测序

Statistics

Farmer John 研究牛群谱系。有 $M$ 头公牛($1 \le M \le 20$)、$F$ 头母牛($1 \le F \le 20$),但不知道谁可能是谁的后代。

他知道每头牛的唯一 DNA 序列 $DNA_{i}$。$DNA_{i}$ 长 $25$,仅含大写 A、$C$、G、T。他想知道哪些牛可能是哪些公母牛对的孩子。

对每对公母牛,输出其他牛中可能是它们孩子的数量,条件为:

  1. 不是任一亲本,母牛不能是自己的母亲,公牛不能是自己的父亲。

  2. 子代 DNA 每一位置匹配两亲本同一位置的至少一个字符。

例如 abc 可来自 (axx, xbc),但不能来自 (aaa, bbb)。

考虑 $3$ 头公牛、$2$ 头母牛的序列:

       Bull 1: GTTTTTTTTTTTTTTTTTTTTTTTT
       Bull 2: AATTTTTTTTTTTTTTTTTTTTTTT
       Bull 3: GATTTTTTTTTTTTTTTTTTTTTTT
       Cow 1:  TTTTTTTTTTTTTTTTTTTTTTTTT
       Cow 2:  ATTTTTTTTTTTTTTTTTTTTTTTT

公牛 $2$ 与母牛 $1$ 可是母牛 $2$ 的父母:

       Bull 2: AATTTTTTTTTTTTTTTTTTTTTTT
       Cow 1:  TTTTTTTTTTTTTTTTTTTTTTTTT
       Cow 2:  ATTTTTTTTTTTTTTTTTTTTTTTT

母牛 $2$ 首字母 A 可来自公牛 $2$,第二字母 T 可来自母牛 $1$,其他字母可来自任一亲本。

目标为矩阵,每个公母牛配对的可能子代数量。

输入格式

  • 第 $1$ 行:空格分隔整数 $M$ 和 $F$。

  • 第 $2..M+1$ 行:第 $i+1$ 行给公牛 $i$ 的序列 $DNA_{i}$。

  • 第 $M+2..M+F+1$ 行:第 $j+M+1$ 行给母牛 $j$ 的序列 $DNA_{j}$。

输出格式

  • 第 $1..M$ 行:第 $i$ 行有 $F$ 个空格分隔整数,第 $j$ 个为公牛 $i$、母牛 $j$ 的可能子代数。

样例

输入格式 1

2 3
TGAAAAAAAAAAAAAAAAAAAAAAA
AGAAAAAAAAAAAAAAAAAAAAAAA
ATAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAA
TTAAAAAAAAAAAAAAAAAAAAAAA

输出格式 1

2 1 0
0 0 2

说明

先 $2$ 头公牛的 DNA,后 $3$ 头母牛的 DNA。

考虑公牛 $1$ 和母牛 $1$:

    b1: TGAAAAAAAAAAAAAAAAAAAAAAA
    c1: ATAAAAAAAAAAAAAAAAAAAAAAA

重要部分可表示为 {T|A} 后跟 {G|T}。

以下是公牛 $0$、母牛 $0$ 的匹配测试:

    b1: TGAAAAAAAAAAAAAAAAAAAAAAA -- parent, can't be offspring
    b2: AGAAAAAAAAAAAAAAAAAAAAAAA offspring! Matches [TA][GT]
    c1: ATAAAAAAAAAAAAAAAAAAAAAAA -- parent, can't be offspring
    c2: AAAAAAAAAAAAAAAAAAAAAAAAA -- second character is 'A'; must be G or T
    c3: TTAAAAAAAAAAAAAAAAAAAAAAA offspring! Matches [TA][GT]

Bull / Cow; parent, can't be offspring; offspring! Matches; second character is A; must be G or T: 公牛;母牛;亲本,不能是子代;子代!匹配;第二个字符为 A,须为 G 或 T

因此结果矩阵首项为 $2$,其他项类似。

出题人:Jacob Steinhardt,2010

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.