結果

問題 No.2708 Jewel holder
ユーザー hiro1729hiro1729
提出日時 2024-03-31 13:36:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 82,572 KB
実行使用メモリ 76,660 KB
最終ジャッジ日時 2024-09-30 18:09:01
合計ジャッジ時間 1,859 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input
R = range
P = print
def I(): return int(S())
def M(): return map(int, S().split())
def L(): return list(M())
def O(): return list(map(int, open(0).read().split()))
def yn(b): print("Yes" if b else "No")
biga = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
smaa = "abcdefghijklmnopqrstuvwxyz"

h, w = M()
a = [S() for _ in R(h)]
ans = 0
for i in R(1 << (h + w - 2)):
	if bin(i).count('1') == h - 1:
		c = 1
		ok = True
		ni, nj = 0, 0
		for j in range(h + w - 2):
			if i & (1 << j):
				ni += 1
			else:
				nj += 1
			if a[ni][nj] == '#':
				ok = False
			elif a[ni][nj] == 'o':
				c += 1
			else:
				c -= 1
			if c < 0:
				ok = False
		if ok:
			ans += 1
print(ans)
0