编程介的小学生 2017-02-17 11:03 采纳率: 20.3%
浏览 1027
已采纳

Genetic Combinations

Statement of the Problem
The population of the small village of Zombiniville is famous fir its genetic characteristics. The inhabitants present only 5 variations on 4 aspects (hair, eyes, nose and feet). Two research companies, Gentec and Genco, tabulated an extensive series of data on the inhabitants of Zombiniville.

Both companies used symbols for the 4 aspects and its variations. Gentec used the groups (A, B, C, D, E), (F, G, H, I, J), (K, L, M, N, O) and (P, Q, R, S, T), which Genco used (a, b, c, d, e), (f, g, h, i, j), (k, l ,m, n, o) and (p, q, r, s, t), but not necessarily for the same group or in the same order inside a group. For example, the group (A, B, C, D, E) from Gentec could correspond to (r, p, t, s, q) from Genco. In other words, "A" corresponds to "r", "B" corresponds to "p", "C" to "t", "D" to "s" and "E" to "q".

Recently the two companies reached an agreement and decided to exchange their research results. However, a group of international activists against human genetic research invaded the offices of the two companies and destroyed part of the reports - exactly the interpretation of the codes.

You and your team were hired to develop a program to establish a relationship among the two notations. As the companies don't want to waste its capital at random, they prepared a battery of tests for your program, before buying it.

Input Format

Each test case has the following data:

  1. A line with n, the number of individuals in the test case. You can assume that 0 < n < 64.
  2. A line with n descriptions (one for each individual) in the Gentec notation. Each notation is constituted by 4 characters, the first in the interval A-E, the second in the interval F-J, the third in K-O and the last in P-T. A notation is separated from the following by exactly one blank space.
  3. A line with n descriptions (for the same individuals, in the same order) in the Genco notation. Each notation is also constituted by 4 characters, the first in the interval a-e, the second in the interval f-j, the third in k-o and the last in p-t. Again, each notation is separated from the following by exactly one blank space.

After a test case, a new one begins. The end of test cases is indicated by n = 0.

You can assume that the test cases are well formed. There are no errors in the input data.

Output Format

For each test case, an association table should be supplied, as in the example below. Note that the pairs are printed in alphabetical order of the capital letters, five per line. Obviously, Gentec and Genco are testing your program, and they don't supply their real data. You can assume that the association table is changed between test cases. You should print only the associations that are unequivocally determined. If there are two or more possibilities for a given letter, you should print a question mark after this letter.

Sample Input

5
AGNP AFNQ BHMP AFNP AGKQ
egmr dgnr ehlp egnr dgms
12
AGNP AFNP BHMP AFNT EFKR CHKQ AGNP AILR DHKT BHKT EIKP BGOR
agnp afnp bhmp afnt efkr chkq agnp ailr dhkt bhkt eikp bgor
0

Sample Output

Test #1:
A-g B-h C-? D-? E-?
F-n G-m H-l I-? J-?
K-s L-? M-p N-r O-?
P-e Q-d R-? S-? T-?
Test #2:
A-a B-b C-c D-d E-e
F-f G-g H-h I-I J-j
K-k L-l M-m N-n O-o
P-p Q-q R-r S-s T-t

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-02-22 14:18
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上