結果
| 問題 |
No.2871 Universal Serial Bus
|
| コンテスト | |
| ユーザー |
みあえ
|
| 提出日時 | 2024-09-09 23:49:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 978 bytes |
| コンパイル時間 | 488 ms |
| コンパイル使用メモリ | 82,368 KB |
| 実行使用メモリ | 386,160 KB |
| 最終ジャッジ日時 | 2024-09-09 23:50:29 |
| 合計ジャッジ時間 | 33,410 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 5 TLE * 6 |
ソースコード
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, 20202020):
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()
みあえ