結果

問題 No.3110 Like CPCTF?
ユーザー YUSUKE OGIWARA
提出日時 2025-04-18 22:27:42
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,007 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 135,476 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-04-18 22:27:45
合計ジャッジ時間 2,398 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<vector>
#include<math.h>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<cmath>
#include<ctime>
#include<bitset>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
using ll = long long;
using vec = vector<ll>;
using Graph = vector<vec>;
using Pair = pair<ll,ll>;

void debug1(vec v){for(auto x:v)cout << x << ' ';cout << endl;}
void debug2(vector<Pair> v){for(auto x:v)cout << '(' << x.first << ',' << x.second << ')' << endl;}
void debug3(Graph v){rep(i,0,v.size()-1)debug1(v[i]);cout << endl;}

int main(){
    int n;cin >> n;
    string s;
    cin >> s;
    s = ' ' + s;
    ll ans = 0;set<char>t;
    rep(i,1,n-4)rep(j,i+1,n-3)rep(k,j+1,n-2)rep(l,k+1,n-1)rep(m,l+1,n){
        t.clear();
        t.insert(s[i]);
        t.insert(s[j]);
        t.insert(s[k]);
        t.insert(s[l]);
        t.insert(s[m]);
        if(s[i] == s[k] and t.size() == 4)ans++;
    }
    cout << ans << endl;
}
0