結果

問題 No.2920 Blood Type
ユーザー lam6er
提出日時 2025-03-20 18:52:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,035 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 53,804 KB
最終ジャッジ日時 2025-03-20 18:53:36
合計ジャッジ時間 2,904 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input().strip()
t = input().strip()

def get_alleles(geno):
    if geno == 'AA':
        return [('A', 1.0)]
    elif geno == 'AB':
        return [('A', 0.5), ('B', 0.5)]
    elif geno == 'AO':
        return [('A', 0.5), ('O', 0.5)]
    elif geno == 'BB':
        return [('B', 1.0)]
    elif geno == 'BO':
        return [('B', 0.5), ('O', 0.5)]
    elif geno == 'OO':
        return [('O', 1.0)]
    else:
        assert False, "Invalid genotype"

s_alleles = get_alleles(s)
t_alleles = get_alleles(t)

pa = pb = pab = po = 0.0

for s_char, s_prob in s_alleles:
    for t_char, t_prob in t_alleles:
        prob = s_prob * t_prob
        alleles = {s_char, t_char}
        if 'A' in alleles:
            if 'B' not in alleles:
                pa += prob
            else:
                pab += prob
        elif 'B' in alleles:
            pb += prob
        else:
            po += prob

pa = int(round(pa * 100))
pb = int(round(pb * 100))
pab = int(round(pab * 100))
po = int(round(po * 100))

print(f"{pa} {pb} {pab} {po}")
0