結果

問題 No.3110 Like CPCTF?
ユーザー 438kujira
提出日時 2025-04-18 22:24:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,163 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 166,816 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-18 22:24:36
合計ジャッジ時間 2,609 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define LLINF 9223372036854775807
#define MOD ll(998244353)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
const double PI = 3.14159265358979;


int main(){
    ll n;
    string s;
    cin >> n;
    cin >> s;
    ll ans = 0;
    for(int i1 = 0; i1 < n; i1++){
        for(int i2 = i1+1; i2 < n; i2++){
            for(int i3 = i2+1; i3 < n; i3++){
                for(int i4 = i3+1; i4 < n; i4++){
                    for(int i5 = i4+1; i5 < n; i5++){
                        set<char> t;
                        t.insert(s[i1]);
                        t.insert(s[i2]);
                        t.insert(s[i3]);
                        t.insert(s[i4]);
                        t.insert(s[i5]); 
                        if(s[i1]==s[i3] && t.size()==4) ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;

}
0