結果

問題 No.3110 Like CPCTF?
ユーザー Iwabuchi Akira
提出日時 2025-04-20 19:21:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 854 ms
コンパイル使用メモリ 67,616 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-20 19:21:28
合計ジャッジ時間 1,713 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;
int main() {
    int n;
    string s;
    int count = 0;
    cin >> n;
    cin >> s;
    if (s.length() < 5) {
        cout << 0 << endl;
        return 0;
    };
    for (int i=0; i<n-4; i++) {
        for (int j=i+1; j<n-3; j++) {
            for (int k=j+1; k<n-2; k++) {
                for (int l=k+1; l<n-1; l++) {
                    for (int m=l+1; m<n; m++) {
                        if (
                            s[i] == s[k] &&
                            s[j] != s[i] &&
                            s[l] != s[i] &&
                            s[m] != s[i] &&
                            s[j] != s[l] &&
                            s[j] != s[m] &&
                            s[l] != s[m]
                        ) {
                            count++;
                        }
                    }
                }
            }
        }
    }
    cout << count << endl;
}
0