結果

問題 No.2178 Payable Magic Items
ユーザー tassei903tassei903
提出日時 2023-01-07 00:12:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 877 ms / 4,000 ms
コード長 877 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 206,804 KB
最終ジャッジ日時 2023-08-21 08:27:50
合計ジャッジ時間 15,023 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
71,552 KB
testcase_01 AC 97 ms
71,412 KB
testcase_02 AC 102 ms
71,300 KB
testcase_03 AC 795 ms
190,232 KB
testcase_04 AC 93 ms
71,632 KB
testcase_05 AC 780 ms
190,740 KB
testcase_06 AC 743 ms
190,256 KB
testcase_07 AC 94 ms
71,564 KB
testcase_08 AC 753 ms
190,228 KB
testcase_09 AC 230 ms
91,060 KB
testcase_10 AC 105 ms
77,176 KB
testcase_11 AC 877 ms
202,496 KB
testcase_12 AC 818 ms
206,108 KB
testcase_13 AC 839 ms
206,572 KB
testcase_14 AC 850 ms
206,804 KB
testcase_15 AC 817 ms
206,212 KB
testcase_16 AC 829 ms
206,636 KB
testcase_17 AC 790 ms
194,016 KB
testcase_18 AC 129 ms
77,924 KB
testcase_19 AC 254 ms
93,368 KB
testcase_20 AC 105 ms
77,232 KB
testcase_21 AC 129 ms
78,188 KB
testcase_22 AC 127 ms
78,088 KB
testcase_23 AC 106 ms
76,984 KB
testcase_24 AC 822 ms
200,960 KB
testcase_25 AC 797 ms
196,616 KB
testcase_26 AC 262 ms
94,644 KB
権限があれば一括ダウンロードができます

ソースコード

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)]
for i in range(n):
    s[i] = (10**k-1)//9*4-s[i]
se = set(s)
ans = len(s)-len(se)

from collections import *
d = defaultdict(int)

def saiki(p, now):
    global ans
    #print(p, now)
    if p == k:
        for i in range(k):
            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