結果
問題 | No.2021 Not A but B |
ユーザー |
![]() |
提出日時 | 2023-05-13 05:23:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 667 bytes |
コンパイル時間 | 958 ms |
コンパイル使用メモリ | 103,936 KB |
最終ジャッジ日時 | 2025-02-12 23:51:34 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <map> #include <set> #include <iomanip> #include <queue> #include <algorithm> #include <numeric> #include <deque> #include <complex> #include <cassert> using namespace std; using ll = long long; int main(){ int N, ans=0; bool f=0; string S; cin >> N >> S; for (int i=0; i<N-1; i++){ if (i && S[i-1] == 'B' && S[i] == 'A' && S[i+1] == 'B') continue; else if (S[i] == 'B' && S[i+1] == 'B'){ if (!f){ ans++; f=1; } continue; } ans++; } cout << ans << endl; return 0; }