結果
問題 | No.2021 Not A but B |
ユーザー |
👑 |
提出日時 | 2022-09-27 23:09:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 336 bytes |
コンパイル時間 | 599 ms |
コンパイル使用メモリ | 68,704 KB |
最終ジャッジ日時 | 2025-02-07 17:35:33 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <iostream>using namespace std;int main(){int n;cin>>n;string s;cin>>s;int ans = n-1;for(int i = 0; s.size()-2 > i; i++){if(s.substr(i,3) == "BAB")ans--;}int t = 0;for(int i = 0; s.size()-1 > i; i++){if(s.substr(i,2) == "BB")t++;}cout << ans-max(0,t-1) << endl;}