結果

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long

ll n, ans = 0;
string s;
void solve(ll i, string t){
  if(t.size() == 5){
    set<char> se;
    REP(i, 5) se.insert(t[i]);
    if(se.size() == 4 and t[0] == t[2])ans++;
    return;
  }
  if(i == n) return;
  solve(i + 1, t);
  solve(i + 1, t + s[i]);
}
int main(){
  cin >> n >> s;
  solve(0, "");
  cout << ans << endl;
}
0