結果

問題 No.2871 Universal Serial Bus
ユーザー 👑 KA37RIKA37RI
提出日時 2024-09-06 23:07:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-09-06 23:07:05
合計ジャッジ時間 1,359 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 WA -
testcase_04 AC 27 ms
10,880 KB
testcase_05 AC 26 ms
10,624 KB
testcase_06 AC 26 ms
10,880 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 26 ms
10,752 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 26 ms
10,880 KB
testcase_13 WA -
testcase_14 AC 27 ms
10,624 KB
testcase_15 AC 27 ms
10,752 KB
testcase_16 AC 27 ms
10,752 KB
testcase_17 AC 26 ms
10,624 KB
testcase_18 AC 27 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def solve(h, w, s, t):
	b = (1 << w) - 1
	conn = all( s[i] ^ t[i] ^ b == 0 for i in range(h) )
	conn_rev = all( s[i] ^ t[~i] ^ b == 0 for i in range(h) )
	ev = 0
	p = 0
	q = 0
	n = 20
	for i in range(n):
		if i % 2 == 0:
			if conn:
				p = (1 - q) * (1 - 2 ** -i)
				q += p
				ev += (i + 1) * p
		else:
			if conn_rev:
				p = (1 - q) * (1 - 2 ** -i)
				q += p
				ev += (i + 1) * p
		print(i, p, q, file=sys.stderr)
				
	return ev if ev < n / 2 else -1

h, w = [int(x) for x in input().split()]
s = [int(input().strip().replace("#", "1").replace(".", "0"), 2) for _ in range(h)]
t = [int(input().strip().replace("#", "1").replace(".", "0"), 2) for _ in range(h)]
print(solve(h, w, s, t))
0