結果

問題 No.2593 Reorder and Mod 120
ユーザー titiatitia
提出日時 2023-12-21 07:03:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 394 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 83,140 KB
最終ジャッジ日時 2023-12-21 07:03:46
合計ジャッジ時間 7,571 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
61,004 KB
testcase_01 AC 48 ms
61,004 KB
testcase_02 AC 146 ms
78,104 KB
testcase_03 AC 162 ms
78,100 KB
testcase_04 AC 140 ms
78,708 KB
testcase_05 AC 46 ms
61,004 KB
testcase_06 AC 145 ms
79,008 KB
testcase_07 AC 48 ms
61,004 KB
testcase_08 AC 47 ms
61,004 KB
testcase_09 AC 46 ms
61,004 KB
testcase_10 AC 48 ms
61,004 KB
testcase_11 AC 358 ms
82,096 KB
testcase_12 AC 387 ms
82,100 KB
testcase_13 AC 369 ms
82,936 KB
testcase_14 AC 356 ms
83,036 KB
testcase_15 AC 384 ms
82,328 KB
testcase_16 AC 356 ms
82,224 KB
testcase_17 AC 356 ms
83,020 KB
testcase_18 AC 381 ms
83,140 KB
testcase_19 AC 365 ms
82,348 KB
testcase_20 AC 370 ms
83,008 KB
testcase_21 AC 394 ms
83,016 KB
testcase_22 AC 370 ms
83,020 KB
testcase_23 AC 370 ms
83,012 KB
testcase_24 AC 68 ms
75,820 KB
testcase_25 AC 68 ms
75,820 KB
testcase_26 AC 68 ms
75,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from copy import deepcopy

N=int(input())
S=input().strip()

C=Counter(S)

Q=[(C,0,0)]

ANS=[0]*120

while Q:
    #print(Q)
    x,keta,mod=Q.pop()

    if keta==5 or max(x.values())==0:
        count=0
        for i in range(10):
            count+=x[str(i)]*int(i)

        ANS[(mod+40*count)%120]=1
        continue

    for i in range(10):
        if x[str(i)]>0:
            x[str(i)]-=1
            Q.append((deepcopy(x),keta+1,(mod+int(i)*(10**keta))%120))
            x[str(i)]+=1
            
print(sum(ANS))
0