結果

問題 No.3110 Like CPCTF?
ユーザー shogo314
提出日時 2025-04-18 20:18:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 379 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,700 KB
実行使用メモリ 78,208 KB
最終ジャッジ日時 2025-04-18 20:18:44
合計ジャッジ時間 6,116 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

from string import ascii_uppercase
from itertools import permutations

N = int(input())
S = input()
ans = 0
for p in permutations(ascii_uppercase, 4):
    dp = [0] * 6
    dp[0] = 1
    for c in S:
        if c == p[3]:
            dp[5] += dp[4]
        if c == p[2]:
            dp[4] += dp[3]
        if c == p[0]:
            dp[3] += dp[2]
        if c == p[1]:
            dp[2] += dp[1]
        if c == p[0]:
            dp[1] += dp[0]
    ans += dp[5]
print(ans)
0