結果

問題 No.3110 Like CPCTF?
ユーザー Yu_212
提出日時 2025-04-19 08:42:20
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 4,446 ms
コンパイル使用メモリ 274,240 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-19 08:42:27
合計ジャッジ時間 4,371 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int iinf = 1e9;
const ll inf = 1e18;

template<typename T>
ostream& operator<<(ostream &o, vector<T> v) {
    for (int i = 0; i < v.size(); i++)
        o << v[i] << (i+1<v.size()?" ":"");
    return o;
}

int main() {
    cin.tie(0)->sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    ll cnt = 0;
    for (int i1 = 0; i1 < n; i1++) {
        for (int i2 = i1+1; i2 < n; i2++) {
            if (s[i1] == s[i2]) continue;
            for (int i3 = i2+1; i3 < n; i3++) {
                if (s[i1] != s[i3] || s[i2] == s[i3]) continue;
                for (int i4 = i3+1; i4 < n; i4++) {
                    if (s[i1] == s[i4] || s[i2] == s[i4] || s[i3] == s[i4]) continue;
                    for (int i5 = i4+1; i5 < n; i5++) {
                        if (s[i1] == s[i5] || s[i2] == s[i5] || s[i3] == s[i5] || s[i4] == s[i5]) continue;
                        cnt++;
                    }
                }
            }
        }
    }
    cout << cnt << endl;
}
0