시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 232 | 144 | 141 | 62.667% |
Farmer John is studying the geneology of his herd. He has M bulls (1 <= M <= 20) and F cows (1 <= F <= 20). He doesn't know, though, which bovines are potential descendants of which other bovines.
Farmer John does know the unique DNA sequence DNA_i of each and every cow and bull on his farm. DNA_i has length 25 characters and contains only upper-case letters 'A', 'C', 'G', and 'T'. He wants to determine which bovines could possibly be children of which pairs of cows and bulls.
Help Farmer John make this determination. For each pair of a cow and a bull, print how many of FJ's other bovines could possibly be their children. A bovine can be a child of a given cow and bull if
So for example, 'abc' could come from pair ('axx', 'xbc'), but not from the pair ('aaa', 'bbb').
Consider three bulls and two cows with these DNA sequences:
Bull 1: GTTTTTTTTTTTTTTTTTTTTTTTT Bull 2: AATTTTTTTTTTTTTTTTTTTTTTT Bull 3: GATTTTTTTTTTTTTTTTTTTTTTT Cow 1: TTTTTTTTTTTTTTTTTTTTTTTTT Cow 2: ATTTTTTTTTTTTTTTTTTTTTTTT
Bull 2 and cow 1 could be the parents of cow 2:
Bull 2: AATTTTTTTTTTTTTTTTTTTTTTT Cow 1: TTTTTTTTTTTTTTTTTTTTTTTTT Cow 2: ATTTTTTTTTTTTTTTTTTTTTTTT
since cow 2's first letter 'A' could be from Bull 2; cow 2's second letter 'T' could come from cow 1; the remainder of the letters could come from either parent.
Your goal is to create a matrix of the count of possible offspring of each pairing of bulls and cows.
2 3 TGAAAAAAAAAAAAAAAAAAAAAAA AGAAAAAAAAAAAAAAAAAAAAAAA ATAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAA TTAAAAAAAAAAAAAAAAAAAAAAA
2 1 0 0 0 2
Consider bull 1 and cow 1:
b1: TGAAAAAAAAAAAAAAAAAAAAAAA c1: ATAAAAAAAAAAAAAAAAAAAAAAA
One might express the important part of their DNA as {T|A} followed by {G|T}
Here's the 'matching' tests for bull 0 and cow 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]
Thus, the first element of the result matrix is 2. Other elements derived similarly.