結果
| 問題 |
No.3110 Like CPCTF?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-09 07:08:12 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 126 ms / 2,000 ms |
| コード長 | 994 bytes |
| コンパイル時間 | 2,858 ms |
| コンパイル使用メモリ | 278,724 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-18 19:30:39 |
| 合計ジャッジ時間 | 5,826 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
ll ans = 0;
string s;
void solve(const string &s, const string &target) {
int m = 5;
ll dp[6] = {};
dp[0] = 1;
for (int i = 0; i < s.size(); ++i) {
for (int j = m - 1; j >= 0; --j) {
if (s[i] == target[j]) {
dp[j + 1] += dp[j];
}
}
}
ans += dp[m];
}
int main(){
cin >> n >> s;
for(char c = 'A'; c <= 'Z'; c++){
for(char p = 'A'; p <= 'Z'; p++){
for(char t = 'A'; t <= 'Z'; t++){
for(char f = 'A'; f <= 'Z'; f++){
set<char> st = {c, p, t, f};
if(st.size() != 4) continue;
string x = "";
x += c;
x += p;
x += c;
x += t;
x += f;
solve(s, x);
}
}
}
}
cout << ans << endl;
}