結果
問題 | No.506 限られたジャパリまん |
ユーザー |
|
提出日時 | 2017-04-21 23:09:31 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 290 ms / 2,000 ms |
コード長 | 1,217 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-06-28 04:12:36 |
合計ジャッジ時間 | 3,063 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
import sysfrom itertools import combinationsmod = 10**9 + 7def solve():h, w, k, p = map(int, input().split())fr = []for i in range(k):x, y, name = input().split()x = int(x)y = int(y)fr.append((x, y, name))max_keiro = -1omit = []for cmb in combinations(range(k), k - p):dp = [[0]*(h + 1) for i in range(w + 1)]taboo = [[False]*(h + 1) for i in range(w + 1)]for i in cmb:x, y, name = fr[i]taboo[y][x] = Truefor x in range(h + 1):if taboo[0][x]:breakdp[0][x] = 1for y in range(w + 1):if taboo[y][0]:breakdp[y][0] = 1for y in range(1, w + 1):for x in range(1, h + 1):if taboo[y][x]:continuedp[y][x] = dp[y - 1][x] + dp[y][x - 1]if dp[w][h] > max_keiro:max_keiro = dp[w][h]omit = set(cmb)print(max_keiro % mod)if max_keiro == 0:returnfor i in range(k):if i not in omit:print(fr[i][2])if __name__ == '__main__':solve()