結果
| 問題 |
No.3110 Like CPCTF?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-18 20:17:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 160 ms / 2,000 ms |
| コード長 | 1,165 bytes |
| コンパイル時間 | 2,309 ms |
| コンパイル使用メモリ | 194,984 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2025-04-18 20:17:56 |
| 合計ジャッジ時間 | 4,556 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
string s; cin >> s;
int answer = 0;
string t = "AAAAA";
while(true){
if(t.at(0) == t.at(2)){
int Se = 0;
bool ok = true;
for(int i=1; i<5; i++){
int c = t.at(i)-'A';
if(Se&(1<<c)){ok = false; break;}
Se |= 1<<c;
}
if(ok){
vector<int> dp(5);
dp.at(0) = 1;
for(auto c : s){
for(int i=4; i>=0; i--){
if(t.at(i) == c){
if(i == 4) answer += dp.at(i);
else dp.at(i+1) += dp.at(i);
}
}
}
}
}
bool ng = false;
for(int i=4; i>=0; i--){
if(i == 0){ng = true; break;}
if(t.at(i) == 'Z') t.at(i) = 'A';
else{t.at(i)++; break;}
}
if(ng) break;
t.at(0) = t.at(2);
}
cout << answer << endl;
}