結果

問題 No.2178 Payable Magic Items
ユーザー MasKoaTSMasKoaTS
提出日時 2023-10-31 23:51:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 651 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 149,596 KB
最終ジャッジ日時 2023-10-31 23:51:16
合計ジャッジ時間 15,162 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,580 KB
testcase_01 AC 37 ms
53,580 KB
testcase_02 AC 37 ms
53,580 KB
testcase_03 AC 935 ms
144,196 KB
testcase_04 AC 37 ms
53,580 KB
testcase_05 AC 880 ms
144,200 KB
testcase_06 AC 891 ms
144,104 KB
testcase_07 WA -
testcase_08 AC 892 ms
144,100 KB
testcase_09 AC 169 ms
88,984 KB
testcase_10 AC 45 ms
62,256 KB
testcase_11 AC 1,001 ms
143,688 KB
testcase_12 AC 992 ms
143,680 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 982 ms
143,680 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 68 ms
73,804 KB
testcase_19 AC 195 ms
92,304 KB
testcase_20 AC 47 ms
64,572 KB
testcase_21 AC 68 ms
73,664 KB
testcase_22 AC 98 ms
74,504 KB
testcase_23 AC 49 ms
64,572 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 201 ms
91,144 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(5 ** m):
    for j in range(m):
        x = i - (5 ** j) * (i // (5 ** j) % 5)
        if((x, j) in visited):
            continue
        visited.add((x, j))
        for k in range(3, -1, -1):
            y = x + (5 ** j) * k
            dp[y] += dp[y + 5 ** j]

ans = sum(dp[item] > 1 for item in items)
print(ans)
0