結果

問題 No.2178 Payable Magic Items
ユーザー MasKoaTSMasKoaTS
提出日時 2023-10-31 23:40:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 614 ms / 4,000 ms
コード長 563 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 82,268 KB
最終ジャッジ日時 2023-10-31 23:40:57
合計ジャッジ時間 11,675 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
60,112 KB
testcase_01 AC 37 ms
53,580 KB
testcase_02 AC 36 ms
53,580 KB
testcase_03 AC 519 ms
78,576 KB
testcase_04 AC 36 ms
53,580 KB
testcase_05 AC 493 ms
78,576 KB
testcase_06 AC 523 ms
78,580 KB
testcase_07 AC 37 ms
53,580 KB
testcase_08 AC 494 ms
78,580 KB
testcase_09 AC 127 ms
76,136 KB
testcase_10 AC 45 ms
62,340 KB
testcase_11 AC 609 ms
82,268 KB
testcase_12 AC 578 ms
82,228 KB
testcase_13 AC 609 ms
82,228 KB
testcase_14 AC 583 ms
82,228 KB
testcase_15 AC 614 ms
82,228 KB
testcase_16 AC 585 ms
82,228 KB
testcase_17 AC 535 ms
80,016 KB
testcase_18 AC 59 ms
68,848 KB
testcase_19 AC 152 ms
77,296 KB
testcase_20 AC 48 ms
62,480 KB
testcase_21 AC 59 ms
68,848 KB
testcase_22 AC 60 ms
70,896 KB
testcase_23 AC 50 ms
64,532 KB
testcase_24 AC 564 ms
81,276 KB
testcase_25 AC 549 ms
79,384 KB
testcase_26 AC 160 ms
77,644 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]

imos = [0] * (5 ** m)
for item in items:
    imos[item] = 1
for i in range(5 ** m):
    for j in range(m):
        x = i - (5 ** j) * (i // (5 ** j) % 5)
        for k in range(3, -1, -1):
            y = x + (5 ** j) * k
            imos[y] += imos[y + 5 ** j]

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