結果

問題 No.2178 Payable Magic Items
コンテスト
ユーザー LyricalMaestro
提出日時 2026-09-13 04:46:39
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 227 ms / 4,000 ms
+ 534µs
コード長 901 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 71 ms
コンパイル使用メモリ 80,896 KB
実行使用メモリ 119,596 KB
最終ジャッジ日時 2026-09-13 04:46:45
合計ジャッジ時間 6,055 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/2178

MOD = 998244353

    
def main():
    N, K = map(int, input().split())
    S = []
    for _ in range(N):
        S.append(input())

    total = 5 ** K
    dp = [0] * total
    maps = {}
    for s__ in S:
        a = 0
        for j in range(K):
            a *= 5
            a += int(s__[j])
        dp[a] += 1
        if a not in maps:
            maps[a] = 0
        maps[a] += 1

    for j in range(K):
        mask = 5 ** (j + 1)
        mask2 = 5 ** j
        for bit in reversed(range(total)):
            bit_ = bit % mask
            bit_ = bit_ // mask2
            if bit_ > 0:
                new_bit = bit - mask2
                dp[new_bit] += dp[bit]

    keep = 0
    for a, v in maps.items():
        v0 = dp[a]
        if v0 == v:
            keep += 1

    print(N - keep)


    



            

    

if __name__ == "__main__":
    main()
0