結果

問題 No.506 限られたジャパリまん
ユーザー mkawa2mkawa2
提出日時 2020-05-21 16:01:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 522 ms / 2,000 ms
コード長 1,460 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 78,776 KB
最終ジャッジ日時 2023-09-10 12:56:35
合計ジャッジ時間 6,569 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,936 KB
testcase_01 AC 91 ms
71,888 KB
testcase_02 AC 107 ms
76,948 KB
testcase_03 AC 92 ms
71,536 KB
testcase_04 AC 522 ms
78,496 KB
testcase_05 AC 518 ms
78,172 KB
testcase_06 AC 92 ms
71,900 KB
testcase_07 AC 99 ms
76,964 KB
testcase_08 AC 216 ms
77,936 KB
testcase_09 AC 166 ms
77,900 KB
testcase_10 AC 119 ms
77,828 KB
testcase_11 AC 337 ms
78,312 KB
testcase_12 AC 221 ms
78,180 KB
testcase_13 AC 91 ms
71,756 KB
testcase_14 AC 118 ms
77,624 KB
testcase_15 AC 98 ms
72,256 KB
testcase_16 AC 202 ms
77,964 KB
testcase_17 AC 150 ms
78,092 KB
testcase_18 AC 231 ms
77,896 KB
testcase_19 AC 132 ms
77,968 KB
testcase_20 AC 310 ms
78,212 KB
testcase_21 AC 315 ms
78,436 KB
testcase_22 AC 498 ms
78,776 KB
testcase_23 AC 210 ms
78,220 KB
testcase_24 AC 125 ms
77,776 KB
権限があれば一括ダウンロードができます

ソースコード

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])

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

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

main()
0