結果

問題 No.3110 Like CPCTF?
ユーザー yuma4869
提出日時 2025-04-19 23:37:29
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 520 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2025-04-19 23:37:31
合計ジャッジ時間 1,882 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations
import sys

def count_cpctf_like_subseq(S: str) -> int:
    N = len(S)
    ans = 0
    for i1, i2, i3, i4, i5 in combinations(range(N), 5):
        a, b, c, d, e = S[i1], S[i2], S[i3], S[i4], S[i5]
        if a == c and b != a and d != a and e != a:
            if b != d and b != e and d != e:
                ans += 1
    return ans

if __name__ == "__main__":
    input = sys.stdin.readline
    N = int(input().strip())
    S = input().strip()
    print(count_cpctf_like_subseq(S))
0