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.