結果
問題 | No.2021 Not A but B |
ユーザー |
|
提出日時 | 2022-07-29 22:20:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 653 bytes |
コンパイル時間 | 1,931 ms |
コンパイル使用メモリ | 193,480 KB |
最終ジャッジ日時 | 2025-01-30 15:26:18 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
typedef long long ll; typedef long double ld; #include <bits/stdc++.h> using namespace std; #define int long long signed main(){ // BB -> 1 // AA -> every 1 // BA -> 1 // AB -> if BAB -> 0 // AAB -> 1 ll n; std::cin >> n; string s; std::cin >> s; ll bb = 0; ll ans= 0; for (int i = 0; i < n-1; i++) { if(s[i]=='B'&&s[i+1]=='B'){ bb=1; }else if(s[i]=='B'){ ans++; }else if(s[i+1]=='B'){ if(i==0||s[i-1]=='A'){ ans++; } }else{ ans++; } } std::cout << ans+bb << std::endl; }