結果

問題 No.2871 Universal Serial Bus
ユーザー みあえ
提出日時 2024-09-09 23:44:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 898 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 82,120 KB
実行使用メモリ 75,792 KB
最終ジャッジ日時 2024-09-09 23:44:47
合計ジャッジ時間 5,168 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(H, W, Ss, Ts):
    odd = all(S + T + 1 == 1 << W for S, T in zip(Ss, Ts))
    even = all(S + T + 1 == 1 << W for S, T in zip(Ss[::-1], Ts))

    e = 0.0
    p = 1.0
    for i in range(1, 2020202):
        if i & 1:
            if odd:
                e += i * p * (1.0 - pow(2, -i + 1))
                p *= pow(2, -i + 1)
        else:
            if even:
                e += i * p * (1.0 - pow(2, -i + 1))
                p *= pow(2, -i + 1)

    return e


def main():
    H, W = map(int, input().split())
    Ss = []
    for _ in range(H):
        line = input()
        line = line.replace(".", "0").replace("#", "1")
        Ss.append(int(line, 2))
    Ts = []
    for _ in range(H):
        line = input()
        line = line.replace(".", "0").replace("#", "1")
        Ts.append(int(line, 2))
    ans = solve(H, W, Ss, Ts)
    print(ans)


if __name__ == "__main__":
    main()
0