結果

問題 No.506 限られたジャパリまん
ユーザー titiatitia
提出日時 2023-07-18 02:03:05
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 865 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 79,184 KB
最終ジャッジ日時 2023-09-10 12:59:01
合計ジャッジ時間 7,451 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,396 KB
testcase_01 RE -
testcase_02 AC 85 ms
76,444 KB
testcase_03 AC 72 ms
71,284 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 138 ms
77,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

H,W,K,P=map(int,input().split())
mod=10**9+7

F=[input().split() for i in range(K)]
for i in range(K):
    F[i][0]=int(F[i][0])
    F[i][1]=int(F[i][1])

MAX=0
ind=0

for i in range(1<<K):
    DP=[[0]*(W+1) for i in range(H+1)]
    DP[0][0]=1

    p=0

    for j in range(K):
        if i & (1<<j) == 0:
            x,y,_ = F[j]
            DP[y][x]=-1
        else:
            p+=1

    if p>P:
        continue

    for j in range(H+1):
        for k in range(W+1):
            if DP[j][k]!=-1:
                if j-1>=0 and DP[j-1][k]!=-1:
                    DP[j][k]+=DP[j-1][k]
                if k-1>=0 and DP[j][k-1]!=-1:
                    DP[j][k]+=DP[j][k-1]

    if DP[-1][-1]>MAX:
        MAX=DP[-1][-1]
        ind=i
            
print(MAX)

for j in range(K):
    if ind & (1<<j) != 0:
        print(F[j][2])
0