結果

問題 No.2021 Not A but B
ユーザー Carpenters-Cat
提出日時 2022-07-29 21:58:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 406 bytes
コンパイル時間 2,092 ms
コンパイル使用メモリ 194,792 KB
最終ジャッジ日時 2025-01-30 15:15:15
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 8 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    string s;
    cin >> s;
    s = "B" + s + "B";
    int ans = 0;
    for (int i = 0; i <= N; i ++) {
        if (s[i] == 'A' || s[i + 1] == 'A') {
            ans ++;
        }
    }
    for (int i = 0; i < N; i ++) {
        if (s.substr(i, 3) == "BAB") {
            ans --;
        }
    }
    cout << ans << endl;
}
0