結果
| 問題 | No.2021 Not A but B |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-29 22:33:42 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 367 bytes |
| 記録 | |
| コンパイル時間 | 2,631 ms |
| コンパイル使用メモリ | 183,736 KB |
| 実行使用メモリ | 191,708 KB |
| 最終ジャッジ日時 | 2026-04-02 17:16:35 |
| 合計ジャッジ時間 | 1,741 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
int main(){
int n;
cin>>n;
string s;
cin>>s;
ll ans=0;
int flg=0;
rep(i,n-1){
if(s.at(i)=='B'){
if(s.at(i)==s.at(i+1)) flg=1;
else if(i+2<n&&s.at(i+2)=='B');
else ans++;
}else ans++;
}
cout<<ans+flg<<endl;
}