結果

問題 No.2178 Payable Magic Items
ユーザー 👑 p-adicp-adic
提出日時 2023-05-29 22:11:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,552 ms / 4,000 ms
コード長 271 bytes
コンパイル時間 64 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 23,080 KB
最終ジャッジ日時 2023-08-27 23:57:30
合計ジャッジ時間 24,221 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,884 KB
testcase_01 AC 15 ms
7,864 KB
testcase_02 AC 14 ms
7,816 KB
testcase_03 AC 1,498 ms
21,280 KB
testcase_04 AC 15 ms
7,812 KB
testcase_05 AC 20 ms
11,128 KB
testcase_06 AC 77 ms
11,648 KB
testcase_07 AC 15 ms
7,820 KB
testcase_08 AC 70 ms
11,640 KB
testcase_09 AC 46 ms
8,964 KB
testcase_10 AC 15 ms
7,804 KB
testcase_11 AC 1,738 ms
18,948 KB
testcase_12 AC 2,478 ms
20,160 KB
testcase_13 AC 2,406 ms
20,172 KB
testcase_14 AC 2,529 ms
22,696 KB
testcase_15 AC 2,552 ms
23,080 KB
testcase_16 AC 2,552 ms
19,944 KB
testcase_17 AC 1,735 ms
14,216 KB
testcase_18 AC 33 ms
8,280 KB
testcase_19 AC 493 ms
10,780 KB
testcase_20 AC 18 ms
7,868 KB
testcase_21 AC 29 ms
7,832 KB
testcase_22 AC 36 ms
8,232 KB
testcase_23 AC 19 ms
7,816 KB
testcase_24 AC 2,141 ms
17,776 KB
testcase_25 AC 1,554 ms
13,204 KB
testcase_26 AC 573 ms
11,628 KB
権限があれば一括ダウンロードができます

ソースコード

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