結果

問題 No.2593 Reorder and Mod 120
ユーザー chineristACchineristAC
提出日時 2023-12-21 10:41:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,208 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 73,564 KB
最終ジャッジ日時 2023-12-21 10:41:22
合計ジャッジ時間 2,669 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
56,240 KB
testcase_01 AC 45 ms
56,240 KB
testcase_02 AC 56 ms
64,820 KB
testcase_03 AC 59 ms
66,904 KB
testcase_04 AC 56 ms
64,820 KB
testcase_05 AC 46 ms
56,240 KB
testcase_06 AC 59 ms
66,904 KB
testcase_07 AC 46 ms
56,240 KB
testcase_08 AC 46 ms
56,240 KB
testcase_09 AC 45 ms
56,240 KB
testcase_10 AC 44 ms
56,240 KB
testcase_11 AC 57 ms
67,040 KB
testcase_12 AC 58 ms
67,032 KB
testcase_13 AC 64 ms
73,544 KB
testcase_14 AC 60 ms
69,088 KB
testcase_15 AC 61 ms
71,400 KB
testcase_16 AC 55 ms
67,040 KB
testcase_17 AC 57 ms
69,088 KB
testcase_18 AC 56 ms
69,092 KB
testcase_19 AC 60 ms
73,524 KB
testcase_20 AC 61 ms
73,564 KB
testcase_21 AC 60 ms
73,564 KB
testcase_22 AC 60 ms
73,564 KB
testcase_23 AC 60 ms
73,564 KB
testcase_24 AC 62 ms
73,552 KB
testcase_25 AC 62 ms
73,552 KB
testcase_26 AC 61 ms
73,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

def solve_brute(N,S):
    L = permutations([i for i in range(N)])
    res = set()
    for p in L:
        tmp = int("".join([S[p[i]] for i in range(N)]))
        res.add(tmp % 120)
    return len(res)

def solve(N,S):
    if N <= 4:
        L = permutations([i for i in range(N)])
        res = set()
        for p in L:
            tmp = int("".join([S[p[i]] for i in range(N)]))
            res.add(tmp % 120)
        return len(res)


    cnt = [0] * 10
    for s in S:
        cnt[int(s)] += 1


    res = set()
    for r in range(100,1000):
        d = []
        for _ in range(3):
            d.append(r % 10)
            r //= 10
        if 0 in d:
            continue

        flg = 1
        for x in range(1,10):
            if d.count(x) > cnt[x]:
                flg = 0
        if flg:
            r = 100 * d[2] + 10 * d[1] + d[0]
            res.add(r % 40)
    return len(res)

N = int(input())
S = input()
print(solve(N,S))
                
0