結果

問題 No.506 限られたジャパリまん
ユーザー convexineqconvexineq
提出日時 2021-02-12 05:46:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 963 ms / 2,000 ms
コード長 771 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 77,812 KB
最終ジャッジ日時 2023-09-10 12:57:29
合計ジャッジ時間 7,001 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,356 KB
testcase_01 AC 75 ms
71,284 KB
testcase_02 AC 85 ms
76,112 KB
testcase_03 AC 74 ms
71,548 KB
testcase_04 AC 582 ms
77,716 KB
testcase_05 AC 584 ms
77,572 KB
testcase_06 AC 73 ms
71,376 KB
testcase_07 AC 86 ms
76,184 KB
testcase_08 AC 191 ms
77,180 KB
testcase_09 AC 151 ms
77,520 KB
testcase_10 AC 103 ms
77,724 KB
testcase_11 AC 335 ms
77,424 KB
testcase_12 AC 205 ms
77,284 KB
testcase_13 AC 73 ms
71,232 KB
testcase_14 AC 90 ms
76,704 KB
testcase_15 AC 74 ms
71,328 KB
testcase_16 AC 219 ms
77,192 KB
testcase_17 AC 137 ms
77,372 KB
testcase_18 AC 230 ms
77,564 KB
testcase_19 AC 103 ms
77,388 KB
testcase_20 AC 332 ms
77,500 KB
testcase_21 AC 339 ms
77,624 KB
testcase_22 AC 963 ms
77,812 KB
testcase_23 AC 323 ms
77,528 KB
testcase_24 AC 99 ms
77,188 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
name = []
pos = []
for _ in range(k):
    x,y,n = input().split()
    name.append(n)
    pos.append((int(x),int(y)))

b = [[1]*w for _ in range(h)]
ans = val = 0
for mask in range(1<<k):
    c = 0
    for i in range(k):
        x,y = pos[i]
        b[x][y] = mask>>i&1
        c += mask>>i&1
    if c > p: continue
    v = solve()
    if val < v:
        ans = mask
        val = v

print(val%(10**9+7))
for i in range(k):
    if ans>>i&1: print(name[i])
0