結果

問題 No.506 限られたジャパリまん
ユーザー H3PO4H3PO4
提出日時 2020-09-06 09:51:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 8,584 KB
最終ジャッジ日時 2023-09-10 12:56:49
合計ジャッジ時間 5,820 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,332 KB
testcase_01 AC 17 ms
8,196 KB
testcase_02 AC 19 ms
8,236 KB
testcase_03 AC 18 ms
8,160 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 17 ms
8,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 32 ms
8,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

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

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)
for i in indices:
    print(name[i])
0