結果
問題 |
No.2178 Payable Magic Items
|
ユーザー |
![]() |
提出日時 | 2023-10-31 23:51:00 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 651 bytes |
コンパイル時間 | 464 ms |
コンパイル使用メモリ | 82,444 KB |
実行使用メモリ | 150,016 KB |
最終ジャッジ日時 | 2024-09-25 17:46:11 |
合計ジャッジ時間 | 14,294 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 WA * 7 |
ソースコード
import sys input = sys.stdin.readline def to_num(s): ret = 0 for c in s: x = ord(c) - ord('0') ret *= 5 ret += x return ret n, m = map(int, input().split()) items = [to_num(input()[:-1]) for _ in [0] * n] dp = [0] * (5 ** m) for item in items: dp[item] = 1 visited = set([]) for i in range(5 ** m): for j in range(m): x = i - (5 ** j) * (i // (5 ** j) % 5) if((x, j) in visited): continue visited.add((x, j)) for k in range(3, -1, -1): y = x + (5 ** j) * k dp[y] += dp[y + 5 ** j] ans = sum(dp[item] > 1 for item in items) print(ans)