結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using ll = long long;
typedef pair<int, int> P;
#define EPS (1e-12)
// const int MOD=1e9+7;
// const int vx[]={0,1,0,-1},vy[]={1,0,-1,0};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    for(int a = 0; a < n; a++) {
        for(int b = a + 1; b < n; b++) {
            for(int c = b + 1; c < n; c++) {
                for(int d = c + 1; d < n; d++) {
                    for(int e = d + 1; e < n; e++) {
                        if(set<char>{s[a], s[b], s[c], s[d], s[e]}.size() != 4) continue;
                        if(s[a] != s[c]) continue;
                        ans++;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}
0