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.