結果

問題 No.2021 Not A but B
ユーザー ksukegamesksukegames
提出日時 2022-08-17 22:35:55
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 951 bytes
コンパイル時間 1,844 ms
コンパイル使用メモリ 141,748 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-05 04:29:45
合計ジャッジ時間 2,504 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <tuple>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cassert>
#include <functional>
#include <numeric>
#include <type_traits>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define coutf(f) cout << fixed << setprecision(f)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
int main() {
int n;
string s;
cin >> n >> s;
int ans = n - 1, base = 0;
rep(i, n - 1) {
if (s[i] == 'B' && s[i + 1] == 'B') {
ans--;
base = 1;
}
}
rep(i, n - 2) {
if (s[i] == 'B' && s[i + 1] == 'A' && s[i + 2] == 'B') ans--;
}
ans += base;
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0