結果

問題 No.2021 Not A but B
ユーザー ぷら
提出日時 2022-07-29 21:32:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 394 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 193,988 KB
最終ジャッジ日時 2025-01-30 14:57:34
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 20 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 1;
    for(int i = 0; i+1 < N; i++) {
        if(S[i] == 'B' && S[i+1] == 'B') {
            continue;
        }
        else if(i && S[i-1] == 'B' && S[i+1] == 'B') {
            continue;
        }
        else {
            ans++;
        }
    }
    cout << ans << endl;
}
0