結果

問題 No.2178 Payable Magic Items
ユーザー MasKoaTSMasKoaTS
提出日時 2023-11-01 19:53:35
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 722 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 81,884 KB
実行使用メモリ 328,380 KB
最終ジャッジ日時 2023-11-01 19:53:40
合計ジャッジ時間 4,006 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,848 KB
testcase_01 AC 31 ms
53,600 KB
testcase_02 AC 31 ms
53,600 KB
testcase_03 RE -
testcase_04 AC 32 ms
53,604 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 31 ms
53,604 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 36 ms
61,800 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 176 ms
328,380 KB
testcase_19 RE -
testcase_20 AC 46 ms
70,704 KB
testcase_21 AC 163 ms
326,280 KB
testcase_22 AC 140 ms
328,340 KB
testcase_23 AC 49 ms
70,704 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def to_num(s):
    ret = 0
    for c in s:
        x = ord(c) - ord('0')
        ret <<= 3
        ret += x
    return ret


N, K = map(int, input().split())
st = list([to_num(input()[:-1]) for _ in [0] * N])

visited = [0] * (1 << (K * 5))
for v_start in st:
    if(visited[v_start] == 1):
        continue
    stk = [v_start]
    while(stk):
        v_now = stk.pop()
        for i in range(0, K * 3, 3):
            if(((v_now >> i) & 7) == 0):
                continue
            v_next = v_now - (1 << i)
            if(visited[v_next] == 1):
                continue
            visited[v_next] = 1
            stk.append(v_next)

ans = sum(visited[x] for x in st)
print(ans)
0