結果
問題 | No.2021 Not A but B |
ユーザー |
|
提出日時 | 2022-07-29 22:33:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 367 bytes |
コンパイル時間 | 1,590 ms |
コンパイル使用メモリ | 166,536 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-19 15:44:32 |
合計ジャッジ時間 | 2,623 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; }