結果

問題 No.2178 Payable Magic Items
ユーザー MasKoaTSMasKoaTS
提出日時 2023-10-31 23:56:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 819 ms / 4,000 ms
コード長 650 bytes
コンパイル時間 1,294 ms
コンパイル使用メモリ 81,884 KB
実行使用メモリ 147,692 KB
最終ジャッジ日時 2023-10-31 23:56:33
合計ジャッジ時間 13,139 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,632 KB
testcase_01 AC 37 ms
53,632 KB
testcase_02 AC 36 ms
53,632 KB
testcase_03 AC 727 ms
135,644 KB
testcase_04 AC 36 ms
53,632 KB
testcase_05 AC 744 ms
135,644 KB
testcase_06 AC 733 ms
135,644 KB
testcase_07 AC 37 ms
53,632 KB
testcase_08 AC 730 ms
135,640 KB
testcase_09 AC 153 ms
89,592 KB
testcase_10 AC 46 ms
62,432 KB
testcase_11 AC 808 ms
146,664 KB
testcase_12 AC 775 ms
146,664 KB
testcase_13 AC 795 ms
146,664 KB
testcase_14 AC 785 ms
146,664 KB
testcase_15 AC 819 ms
146,664 KB
testcase_16 AC 796 ms
146,664 KB
testcase_17 AC 761 ms
147,692 KB
testcase_18 AC 72 ms
74,820 KB
testcase_19 AC 175 ms
92,268 KB
testcase_20 AC 49 ms
64,624 KB
testcase_21 AC 72 ms
73,912 KB
testcase_22 AC 77 ms
76,592 KB
testcase_23 AC 52 ms
64,632 KB
testcase_24 AC 808 ms
139,260 KB
testcase_25 AC 730 ms
140,632 KB
testcase_26 AC 189 ms
92,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def to_num(s):
    ret = 0
    for c in s:
        x = ord(c) - ord('0')
        ret *= 5
        ret += x
    return ret


n, m = map(int, input().split())
items = [to_num(input()[:-1]) for _ in [0] * n]

dp = [0] * (5 ** m)
for item in items:
    dp[item] = 1
visited = set([])
for i in range(m):
    for j in range(5 ** m):
        x = j - (5 ** i) * (j // (5 ** i) % 5)
        if((x, i) in visited):
            continue
        visited.add((x, i))
        for k in range(3, -1, -1):
            y = x + (5 ** i) * k
            dp[y] += dp[y + 5 ** i]
ans = sum(dp[item] > 1 for item in items)
print(ans)
0