結果

問題 No.2708 Jewel holder
ユーザー hiro1729hiro1729
提出日時 2024-03-31 13:36:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,140 KB
最終ジャッジ日時 2024-03-31 13:36:55
合計ジャッジ時間 2,086 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 35 ms
53,460 KB
testcase_08 AC 46 ms
64,300 KB
testcase_09 AC 40 ms
59,716 KB
testcase_10 AC 44 ms
62,212 KB
testcase_11 AC 49 ms
66,356 KB
testcase_12 AC 35 ms
53,460 KB
testcase_13 AC 56 ms
68,448 KB
testcase_14 AC 36 ms
53,460 KB
testcase_15 AC 69 ms
72,840 KB
testcase_16 AC 40 ms
53,460 KB
testcase_17 AC 150 ms
76,140 KB
testcase_18 AC 102 ms
75,944 KB
testcase_19 AC 85 ms
75,760 KB
権限があれば一括ダウンロードができます

ソースコード

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