結果

問題 No.3110 Like CPCTF?
ユーザー koufu193
提出日時 2025-04-18 22:14:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 455 ms
コンパイル使用メモリ 82,648 KB
実行使用メモリ 76,504 KB
最終ジャッジ日時 2025-04-18 22:14:43
合計ジャッジ時間 2,167 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

input()
S = input().strip()
N = len(S)
count = 0

for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            for l in range(k+1, N):
                for m in range(l+1, N):
                    a, b, c, d, e = S[i], S[j], S[k], S[l], S[m]
                    if a != c:
                        continue  # s1 == s3 ではないのでNG
                    # s1==s3 なので s1 と s3 は a としてOK
                    # 残りの文字 b, d, e と a がすべて異なる必要がある
                    if len(set([a, b, d, e])) != 4:
                        continue
                    # さらに b, d, e が互いに異なることを確認(たとえば a と違うが b==d とかはNG)
                    if len(set([b, d, e])) != 3:
                        continue
                    count += 1

print(count)
0