結果
| 問題 | No.506 限られたジャパリまん | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-09-06 09:56:24 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 947 ms / 2,000 ms | 
| コード長 | 718 bytes | 
| コンパイル時間 | 94 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 11,136 KB | 
| 最終ジャッジ日時 | 2024-06-28 04:24:56 | 
| 合計ジャッジ時間 | 5,892 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 | 
ソースコード
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])
            
            
            
        