結果
問題 |
No.3110 Like CPCTF?
|
ユーザー |
![]() |
提出日時 | 2025-08-26 01:24:24 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 920 bytes |
コンパイル時間 | 3,274 ms |
コンパイル使用メモリ | 286,084 KB |
実行使用メモリ | 14,856 KB |
最終ジャッジ日時 | 2025-08-26 01:24:29 |
合計ジャッジ時間 | 4,306 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/modint> using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N; cin >> N; string s; cin >> s; if (N<=4){ cout << 0 << endl; return 0; } vector<int> w; vector<vector<int>> v; auto dfs=[&](auto self, int now, int x)->void{ if (now == 5){ if (w.size() == 5) v.push_back(w); return; } for (int i=x; i<N; i++){ w.push_back(i); self(self, now+1, i+1); w.pop_back(); } }; int ans=0; dfs(dfs, 0, 0); for (auto &x : v){ set<char> st = {s[x[0]], s[x[1]], s[x[2]], s[x[3]], s[x[4]]}; if (s[x[0]] == s[x[2]] && st.size() == 4) ans++; } cout << ans << endl; return 0; }