結果

問題 No.2178 Payable Magic Items
ユーザー tassei903tassei903
提出日時 2023-01-07 00:01:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 183,216 KB
最終ジャッジ日時 2024-05-08 13:44:29
合計ジャッジ時間 10,060 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
54,016 KB
testcase_01 AC 42 ms
53,760 KB
testcase_02 AC 43 ms
54,144 KB
testcase_03 AC 515 ms
174,428 KB
testcase_04 AC 45 ms
53,888 KB
testcase_05 WA -
testcase_06 AC 503 ms
174,188 KB
testcase_07 AC 44 ms
53,888 KB
testcase_08 AC 509 ms
173,996 KB
testcase_09 AC 164 ms
88,592 KB
testcase_10 AC 54 ms
63,616 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 80 ms
76,672 KB
testcase_23 AC 56 ms
64,896 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

n, k = na()
s = [int(input()) for j in range(n)]

se = set(s)
from collections import *
d = defaultdict(int)
ans = 0
def saiki(p, now):
    global ans
    #print(p, now)
    if p == k:
        for i in range(5):
            if (now//(10**i))%(10**(i+1)):
                d[now] |= d[now-10**i]
        if now in se:
            ans += d[now]
            d[now] = 1
        return
    for i in range(5):
        saiki(p+1, now * 10 + i)

saiki(0,0)
print(ans)
0