結果

問題 No.2871 Universal Serial Bus
ユーザー みあえ
提出日時 2024-09-09 23:50:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 977 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 235,664 KB
最終ジャッジ日時 2024-09-09 23:50:24
合計ジャッジ時間 5,481 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 = []
    p = 1.0
    for i in range(1, 2020202):
        if i & 1:
            if odd:
                e = i * p * (1.0 - pow(2, -i + 1))
                E.append(e)
                p *= pow(2, -i + 1)
        else:
            if even:
                e = i * p * (1.0 - pow(2, -i + 1))
                E.append(e)
                p *= pow(2, -i + 1)

    ans = sum(E[::-1])

    return ans


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