結果
| 問題 |
No.2871 Universal Serial Bus
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-06 21:46:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 545 bytes |
| コンパイル時間 | 226 ms |
| コンパイル使用メモリ | 82,160 KB |
| 実行使用メモリ | 54,716 KB |
| 最終ジャッジ日時 | 2024-09-06 21:46:49 |
| 合計ジャッジ時間 | 1,690 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 |
ソースコード
H, W = map(int, input().split()) S = [input() for _ in range(H)] T = [input() for _ in range(H)] ok1 = True for i in range(H): for j in range(W): if S[i][j] == T[i][j]: ok1 = False ok2 = True for i in range(H): for j in range(W): if S[H - 1 - i][W - 1 - j] == T[i][j]: ok2 = False if (not ok1) and (not ok2): print(-1) exit() ans = 0 now_prob = 1 for i in range(1, 200): if not((i % 2 == 1 and ok1) or (i % 2 == 0 and ok2)): continue prob = 1 - (2 ** (1 - i)) ans += now_prob * prob * i now_prob -= now_prob * prob print(ans)