結果

問題 No.2178 Payable Magic Items
ユーザー lam6er
提出日時 2025-04-15 23:07:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 648 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 82,232 KB
実行使用メモリ 313,760 KB
最終ジャッジ日時 2025-04-15 23:09:41
合計ジャッジ時間 24,783 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 TLE * 1
other AC * 4 TLE * 4 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

n, k = map(int, input().split())

input_tuples = set()
for _ in range(n):
    s = input().strip()
    t = tuple(map(int, s))
    input_tuples.add(t)

all_tuples = list(itertools.product(range(5), repeat=k))

freq = {t: 1 if t in input_tuples else 0 for t in all_tuples}

for d in range(k):
    sorted_tuples = sorted(all_tuples, key=lambda x: -x[d])
    for s in sorted_tuples:
        v = s[d]
        if v < 4:
            s_plus = list(s)
            s_plus[d] += 1
            s_plus = tuple(s_plus)
            freq[s] += freq[s_plus]

answer = 0
for s in input_tuples:
    if freq[s] >= 2:
        answer += 1

print(answer)
0