結果

問題 No.2021 Not A but B
ユーザー yukster714
提出日時 2023-04-21 23:14:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,490 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 168,256 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-06 16:39:44
合計ジャッジ時間 25,848 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define all(x) x.begin(),x.end() 
#define yesif(x) cout << ((x) ? "Yes": "No") << endl
#define myceil(a, b) (a+b-1)/b 
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    bool bx = false;
    bool bb = false;
    rep(i,n-1){
        string t = s;
        if(bx and s[i+1] == 'B') {
            bx = s[i] =='B';
            continue;
        }
        bx = s[i] =='B';
        if(s[i] == 'B' and s[i+1] == 'B') {
            bb = true;
            continue;
        }
        ans++;

    }
    if(bb) ans++;
    cout << ans << endl;
    return 0;
}

0