結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,816 KB
testcase_01 AC 16 ms
7,816 KB
testcase_02 AC 16 ms
7,856 KB
testcase_03 AC 1,735 ms
11,176 KB
testcase_04 AC 15 ms
7,868 KB
testcase_05 AC 22 ms
11,216 KB
testcase_06 AC 88 ms
11,128 KB
testcase_07 AC 16 ms
7,872 KB
testcase_08 AC 79 ms
11,188 KB
testcase_09 AC 52 ms
8,636 KB
testcase_10 AC 17 ms
7,860 KB
testcase_11 AC 1,413 ms
18,908 KB
testcase_12 AC 2,240 ms
19,108 KB
testcase_13 AC 2,169 ms
19,048 KB
testcase_14 AC 2,152 ms
19,172 KB
testcase_15 AC 2,258 ms
19,152 KB
testcase_16 AC 2,130 ms
19,008 KB
testcase_17 AC 1,834 ms
13,764 KB
testcase_18 AC 30 ms
8,320 KB
testcase_19 AC 409 ms
10,368 KB
testcase_20 AC 18 ms
7,844 KB
testcase_21 AC 28 ms
8,244 KB
testcase_22 AC 32 ms
8,224 KB
testcase_23 AC 18 ms
7,824 KB
testcase_24 AC 2,008 ms
16,756 KB
testcase_25 AC 1,757 ms
12,140 KB
testcase_26 AC 478 ms
11,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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