結果

問題 No.2178 Payable Magic Items
ユーザー roarisroaris
提出日時 2023-01-08 16:10:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 392 ms / 4,000 ms
コード長 589 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 84,076 KB
最終ジャッジ日時 2023-08-22 02:23:58
合計ジャッジ時間 7,381 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,368 KB
testcase_01 AC 66 ms
71,476 KB
testcase_02 AC 66 ms
71,292 KB
testcase_03 AC 171 ms
82,584 KB
testcase_04 AC 66 ms
71,364 KB
testcase_05 AC 177 ms
82,360 KB
testcase_06 AC 176 ms
82,560 KB
testcase_07 AC 70 ms
71,648 KB
testcase_08 AC 174 ms
82,192 KB
testcase_09 AC 97 ms
77,312 KB
testcase_10 AC 73 ms
76,388 KB
testcase_11 AC 383 ms
84,008 KB
testcase_12 AC 391 ms
83,856 KB
testcase_13 AC 392 ms
84,072 KB
testcase_14 AC 388 ms
83,792 KB
testcase_15 AC 383 ms
83,932 KB
testcase_16 AC 388 ms
83,940 KB
testcase_17 AC 259 ms
83,744 KB
testcase_18 AC 102 ms
77,740 KB
testcase_19 AC 153 ms
79,024 KB
testcase_20 AC 80 ms
76,640 KB
testcase_21 AC 102 ms
77,832 KB
testcase_22 AC 104 ms
77,676 KB
testcase_23 AC 87 ms
76,796 KB
testcase_24 AC 342 ms
84,076 KB
testcase_25 AC 221 ms
83,896 KB
testcase_26 AC 167 ms
78,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def fs(l):
    res = 0
    
    for i in range(K):
        res += l[i]*pow(5, i)
    
    return res

N, K = map(int, input().split())
exist = [0]*pow(5, K)
cnt = [0]*pow(5, K)

for _ in range(N):
    l = list(map(int, list(input()[:-1])))
    exist[fs(l)] = 1
    cnt[fs(l)] = 1

for d in range(K):
    for S in range(pow(5, K)-1, -1, -1):
        v = S//pow(5, d)%5
        
        if v<4:
            nS = S+pow(5, d)
            cnt[S] += cnt[nS]

ans = 0

for S in range(pow(5, K)):
    if exist[S]==1 and cnt[S]>1:
        ans += 1

print(ans)
0