結果
| 問題 |
No.3110 Like CPCTF?
|
| コンテスト | |
| ユーザー |
hiromi_ayase
|
| 提出日時 | 2025-04-18 20:38:59 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 873 bytes |
| コンパイル時間 | 5,621 ms |
| コンパイル使用メモリ | 332,268 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-18 20:39:15 |
| 合計ジャッジ時間 | 7,199 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define FAST_IO \
ios::sync_with_stdio(false); \
cin.tie(0);
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;
int dfs(int d, int i, string &S, vector<char> &a) {
if (d == a.size()) {
set<char> st;
for (int j = 0; j < a.size(); j++) {
st.insert(a[j]);
}
if (a[0] == a[2] && st.size() == 4) {
return 1;
}
return 0;
}
int ans = 0;
for (int j = i; j < S.size(); j++) {
a[d] = S[j];
ans += dfs(d + 1, j + 1, S, a);
}
return ans;
}
int main() {
FAST_IO
auto ans = 0LL;
int N;
cin >> N;
string S;
cin >> S;
vector<char> a(5);
ans = dfs(0, 0, S, a);
cout << ans << endl;
}
hiromi_ayase