結果

問題 No.2178 Payable Magic Items
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-01-07 19:26:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 906 ms / 4,000 ms
コード長 931 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 86,500 KB
実行使用メモリ 181,640 KB
最終ジャッジ日時 2023-08-21 09:15:47
合計ジャッジ時間 12,668 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,880 KB
testcase_01 AC 72 ms
71,320 KB
testcase_02 AC 73 ms
71,420 KB
testcase_03 AC 561 ms
101,508 KB
testcase_04 AC 71 ms
71,280 KB
testcase_05 AC 367 ms
79,996 KB
testcase_06 AC 379 ms
80,128 KB
testcase_07 AC 71 ms
71,360 KB
testcase_08 AC 366 ms
80,208 KB
testcase_09 AC 144 ms
77,604 KB
testcase_10 AC 92 ms
76,376 KB
testcase_11 AC 620 ms
157,584 KB
testcase_12 AC 841 ms
180,260 KB
testcase_13 AC 845 ms
181,532 KB
testcase_14 AC 871 ms
181,640 KB
testcase_15 AC 906 ms
181,552 KB
testcase_16 AC 900 ms
181,584 KB
testcase_17 AC 670 ms
127,616 KB
testcase_18 AC 109 ms
77,892 KB
testcase_19 AC 216 ms
96,872 KB
testcase_20 AC 100 ms
76,740 KB
testcase_21 AC 109 ms
77,744 KB
testcase_22 AC 109 ms
78,140 KB
testcase_23 AC 99 ms
76,740 KB
testcase_24 AC 762 ms
157,436 KB
testcase_25 AC 608 ms
112,296 KB
testcase_26 AC 235 ms
103,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

"""

import sys
from sys import stdin

def encode(lis):
    now = 0
    for j in range(K):
        now *= 5
        now += int(lis[j])
    return now

N,K = map(int,stdin.readline().split())

S = [ list(stdin.readline()[:-1]) for i in range(N) ]

dp = [0] * (5**K)

for i in range(N):

    now = 0
    for j in range(K):
        now *= 5
        now += int(S[i][j])

    dp[now] += 1

for i in range(len(dp)-1,-1,-1):

    dec = []
    itmp = i
    for j in range(K):
        dec.append(itmp % 5)
        itmp //= 5
    dec.reverse()

    #print (i,dec,"qopqowq")

    for j in range(K):
        dec[j] -= 1
        if dec[j] >= 0:
            enc = encode(dec)
            #print (i,dec,enc)
            dp[enc] += dp[i]
        dec[j] += 1



ans = 0    
for i in range(N):

    now = 0
    for j in range(K):
        now *= 5
        now += int(S[i][j])

    if dp[now] > 1:
        ans += 1

#print (dp)
print (ans)
    
0