結果

問題 No.506 限られたジャパリまん
ユーザー H3PO4H3PO4
提出日時 2020-09-06 09:56:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 936 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 8,656 KB
最終ジャッジ日時 2023-09-10 12:56:52
合計ジャッジ時間 5,706 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,148 KB
testcase_01 AC 15 ms
8,332 KB
testcase_02 AC 17 ms
8,284 KB
testcase_03 AC 16 ms
8,124 KB
testcase_04 AC 25 ms
8,240 KB
testcase_05 AC 17 ms
8,364 KB
testcase_06 AC 16 ms
8,188 KB
testcase_07 AC 24 ms
8,216 KB
testcase_08 AC 936 ms
8,656 KB
testcase_09 AC 384 ms
8,284 KB
testcase_10 AC 27 ms
8,224 KB
testcase_11 AC 820 ms
8,328 KB
testcase_12 AC 504 ms
8,280 KB
testcase_13 AC 17 ms
8,308 KB
testcase_14 AC 21 ms
8,352 KB
testcase_15 AC 17 ms
8,260 KB
testcase_16 AC 718 ms
8,268 KB
testcase_17 AC 38 ms
8,304 KB
testcase_18 AC 42 ms
8,212 KB
testcase_19 AC 88 ms
8,320 KB
testcase_20 AC 204 ms
8,184 KB
testcase_21 AC 64 ms
8,324 KB
testcase_22 AC 248 ms
8,328 KB
testcase_23 AC 166 ms
8,292 KB
testcase_24 AC 30 ms
8,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

H, W, K, P = map(int, input().split())
MOD = 1000000007

coordinates = dict()
name = [''] * K
for i in range(K):
    x, y, n = input().split()
    coordinates[(int(y), int(x))] = i
    name[i] = n

ans = 0
indices = ()
for t in itertools.combinations(range(K), P):
    table = [[0] * (H + 2) for _ in range(W + 2)]
    table[1][1] = 1
    it = itertools.product(range(W + 1), range(H + 1))
    next(it)
    for w, h in it:
        if (w, h) not in coordinates or coordinates[(w, h)] in t:
            table[w + 1][h + 1] = table[w][h + 1] + table[w + 1][h]
    if ans < table[W + 1][H + 1]:
        indices = t
        ans = table[W + 1][H + 1]

print(ans % MOD)
for i in indices:
    print(name[i])
0