結果

問題 No.506 限られたジャパリまん
ユーザー convexineqconvexineq
提出日時 2021-02-12 05:55:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 86,508 KB
実行使用メモリ 77,668 KB
最終ジャッジ日時 2023-09-10 12:57:28
合計ジャッジ時間 4,072 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
70,992 KB
testcase_01 AC 75 ms
71,244 KB
testcase_02 AC 79 ms
75,212 KB
testcase_03 AC 77 ms
70,828 KB
testcase_04 AC 88 ms
75,760 KB
testcase_05 AC 82 ms
75,548 KB
testcase_06 AC 75 ms
71,176 KB
testcase_07 AC 88 ms
76,084 KB
testcase_08 AC 129 ms
76,904 KB
testcase_09 AC 126 ms
77,668 KB
testcase_10 AC 92 ms
76,036 KB
testcase_11 AC 124 ms
77,088 KB
testcase_12 AC 115 ms
76,716 KB
testcase_13 AC 77 ms
71,420 KB
testcase_14 AC 83 ms
75,716 KB
testcase_15 AC 75 ms
71,032 KB
testcase_16 AC 136 ms
77,060 KB
testcase_17 AC 90 ms
76,088 KB
testcase_18 AC 91 ms
76,464 KB
testcase_19 AC 97 ms
76,472 KB
testcase_20 AC 116 ms
77,380 KB
testcase_21 AC 96 ms
76,604 KB
testcase_22 AC 134 ms
77,392 KB
testcase_23 AC 127 ms
76,924 KB
testcase_24 AC 91 ms
76,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    dp = [[0]*w for _ in range(h)]
    dp[0][0] = 1
    for i in range(h):
        for j in range(w):
            if i==0==j or b[i][j]==0: continue
            if i: dp[i][j] += dp[i-1][j]
            if j: dp[i][j] += dp[i][j-1]
    return dp[-1][-1]

h,w,k,p = map(int,input().split())
h += 1; w += 1
pos = []
for _ in range(k):
    x,y,s = input().split()
    pos.append((int(x),int(y),s))

b = [[1]*w for _ in range(h)]
ans = []
val = 0
from itertools import combinations
for lst in combinations(pos,p):
    for x,y,s in pos:
        b[x][y] = 0
    for x,y,s in lst:
        b[x][y] = 1
    v = solve()
    if val < v:
        ans = [xys[2] for xys in lst]
        val = v

print(val%(10**9+7))
for i in ans: print(i)
0