結果
| 問題 |
No.2021 Not A but B
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2024-12-14 00:36:20 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 548 bytes |
| コンパイル時間 | 2,824 ms |
| コンパイル使用メモリ | 246,508 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-14 00:36:25 |
| 合計ジャッジ時間 | 4,329 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
int n;
string s;
cin >> n >> s;
int ans = 0;
rep(i, n - 1) {
if (s.substr(i, 2) == "AA") ++ans;
}
rep(i, n) {
if (s[i] == 'A' && ((i - 1 >= 0 && s[i - 1] == 'B') || (i + 1 < n && s[i + 1] == 'B'))) ++ans;
}
if (s.contains("BB")) ++ans;
cout << ans << endl;
return 0;
}
a01sa01to