結果

問題 No.2178 Payable Magic Items
ユーザー 👑 p-adic
提出日時 2023-05-29 22:11:55
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 3,189 ms / 4,000 ms
コード長 271 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 25,472 KB
最終ジャッジ日時 2024-12-28 10:28:25
合計ジャッジ時間 30,013 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

I,R=input,range
N,K=map(int,I().split())
p=[pow(5,i)for i in R(K+1)]
S=[int(I(),5)for i in R(N)]
b=[0]*p[K]
for s in S:b[s]=1
a=0
for s in S:
	L={s}
	while len(L):
		s=L.pop()
		for q in p:
			if s%(q*5)//q*(b[s-q]<2):
				L.add(s-q)
				a,b[s-q]=a+(b[s-q]==1),2
print(a)
0