結果

問題 No.2593 Reorder and Mod 120
ユーザー ntudantuda
提出日時 2023-12-23 11:56:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 402 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,324 KB
最終ジャッジ日時 2023-12-23 11:56:04
合計ジャッジ時間 2,958 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,588 KB
testcase_01 WA -
testcase_02 AC 40 ms
55,740 KB
testcase_03 AC 41 ms
58,824 KB
testcase_04 AC 42 ms
58,828 KB
testcase_05 AC 39 ms
53,588 KB
testcase_06 AC 43 ms
58,828 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 51 ms
68,532 KB
testcase_12 AC 52 ms
70,580 KB
testcase_13 AC 64 ms
76,296 KB
testcase_14 AC 55 ms
72,628 KB
testcase_15 AC 62 ms
76,220 KB
testcase_16 AC 52 ms
70,580 KB
testcase_17 AC 56 ms
72,628 KB
testcase_18 AC 56 ms
72,628 KB
testcase_19 AC 63 ms
76,272 KB
testcase_20 AC 65 ms
76,324 KB
testcase_21 AC 65 ms
76,196 KB
testcase_22 AC 64 ms
76,324 KB
testcase_23 AC 64 ms
76,324 KB
testcase_24 AC 54 ms
73,636 KB
testcase_25 AC 55 ms
73,636 KB
testcase_26 AC 54 ms
73,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from itertools import permutations

dic = defaultdict(int)
N = int(input())
S = input()
sum0 = 0
for s in S:
    s = int(s)
    dic[s] += 1
    sum0 += s
X = []
for k, v in dic.items():
    X += [k] * (min(3, v))

Y = set()
for a, b, c in set(permutations(X, 3)):
    y = a * 100 + b * 10 + c + 40 * ((sum0 - a - b - c) % 3)
    y %= 120
    Y.add(y)

print(len(Y))
0