結果

問題 No.506 限られたジャパリまん
ユーザー nanaenanae
提出日時 2017-04-21 23:01:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,178 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 8,396 KB
最終ジャッジ日時 2023-09-10 12:51:36
合計ジャッジ時間 2,788 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,252 KB
testcase_01 AC 16 ms
8,384 KB
testcase_02 AC 16 ms
8,260 KB
testcase_03 AC 16 ms
8,324 KB
testcase_04 AC 19 ms
8,236 KB
testcase_05 AC 17 ms
8,376 KB
testcase_06 AC 16 ms
8,232 KB
testcase_07 AC 19 ms
8,396 KB
testcase_08 AC 272 ms
8,344 KB
testcase_09 AC 135 ms
8,360 KB
testcase_10 AC 20 ms
8,232 KB
testcase_11 AC 238 ms
8,228 KB
testcase_12 AC 142 ms
8,356 KB
testcase_13 AC 16 ms
8,188 KB
testcase_14 AC 18 ms
8,236 KB
testcase_15 AC 16 ms
8,256 KB
testcase_16 AC 254 ms
8,380 KB
testcase_17 AC 22 ms
8,380 KB
testcase_18 AC 22 ms
8,244 KB
testcase_19 AC 37 ms
8,276 KB
testcase_20 AC 68 ms
8,248 KB
testcase_21 AC 29 ms
8,340 KB
testcase_22 AC 79 ms
8,300 KB
testcase_23 AC 55 ms
8,376 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import combinations

mod = 10**9 + 7

def 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 = -1
    omit = []

    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] = True

        for x in range(h + 1):
            if taboo[0][x]:
                break
            dp[0][x] = 1

        for y in range(w + 1):
            if taboo[y][0]:
                break
            dp[y][0] = 1

        for y in range(1, w + 1):
            for x in range(1, h + 1):
                if taboo[y][x]:
                    continue

                dp[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)

    for i in range(k):
        if i not in omit:
            print(fr[i][2])

if __name__ == '__main__':
    solve()
0