結果

問題 No.506 限られたジャパリまん
ユーザー mkawa2mkawa2
提出日時 2020-05-21 15:59:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,460 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 13,232 KB
最終ジャッジ日時 2023-09-10 12:56:28
合計ジャッジ時間 3,696 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    md=10**9+7
    h,w,k,p=MI()
    friends=[SI().split() for _ in range(k)]
    ans=0
    abit=(1<<k)-1
    for bit in range(1<<k):
        if k-bin(bit).count("1")>p:continue
        dp=[[0]*(w+2) for _ in range(h+2)]
        for fi in range(k):
            if bit>>fi&1:
                i,j,_=friends[fi]
                dp[int(i)+1][int(j)+1]=-1
        dp[0][1]=1

        for i in range(h+1):
            for j in range(w+1):
                if dp[i+1][j+1]==-1:dp[i+1][j+1]=0
                else:dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j])%md

        if dp[h+1][w+1]>ans:
            ans=dp[h+1][w+1]
            abit=bit

    print(ans)
    for fi in range(k):
        if abit>>fi&1==0:print(friends[fi][2])

main()
0