結果
| 問題 | No.2593 Reorder and Mod 120 | 
| コンテスト | |
| ユーザー |  titia | 
| 提出日時 | 2023-12-21 06:54:12 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 520 bytes | 
| コンパイル時間 | 351 ms | 
| コンパイル使用メモリ | 82,960 KB | 
| 実行使用メモリ | 78,764 KB | 
| 最終ジャッジ日時 | 2024-09-27 10:47:00 | 
| 合計ジャッジ時間 | 3,680 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 9 WA * 17 | 
ソースコード
from collections import Counter
from copy import deepcopy
N=int(input())
S=input()
C=Counter(S)
Q=[(C,0,0)]
ANS=[0]*120
while Q:
    x,keta,mod=Q.pop()
    if keta==3 or max(x.values())==0:
        count=0
        for i in range(10):
            count+=x[str(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))
            
            
            
        