結果
問題 | No.2021 Not A but B |
ユーザー |
|
提出日時 | 2022-07-29 21:37:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 531 bytes |
コンパイル時間 | 1,726 ms |
コンパイル使用メモリ | 166,952 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 13:49:41 |
合計ジャッジ時間 | 2,689 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define IO ios_base::sync_with_stdio(0);cin.tie(0);#define endl '\n'int main() {IO;int n; cin >> n;string s; cin >> s;int res = 0;bool check = false;for (int i = 0; i < (int)s.size() - 1; ++i)if (s[i] == 'B' && s[i + 1] == 'B') check = true;else if (s[i] == 'A' && s[i + 1] == 'A' || s[i] == 'B' && s[i + 1] == 'A') ++res;else if (i == 0 || s[i - 1] == 'A') ++res;cout << res + check << endl;return 0;}