結果

問題 No.2178 Payable Magic Items
ユーザー ニックネーム
提出日時 2023-01-07 00:56:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 415 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 116,940 KB
最終ジャッジ日時 2024-12-14 18:21:34
合計ジャッジ時間 18,015 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit
from functools import lru_cache
setrecursionlimit(10**6)
n,k = map(int,input().split())
a = {tuple(map(int,input())) for _ in range(n)}
@lru_cache(maxsize=None)
def main(s):
    for i in range(k):
        if s[i]:
            t = list(s); t[i] -= 1; t = tuple(t)
            if t in a or main(t): return True
    return False
ans = 0
for s in a:
    if main(s): ans += 1
print(ans)
0