結果

問題 No.672 最長AB列
ユーザー phsplsphspls
提出日時 2020-04-21 00:06:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 537 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 162,436 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 01:05:18
合計ジャッジ時間 2,733 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 7 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 6 ms
5,376 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long

int main() {
    string s;
    cin >> s;

    bool is_a = false;
    int alen = 0;
    int blen = 0;
    int result = 0;
    for(char c: s) {
        if(c == 'A') {
            if(!is_a) alen = 0;
            alen += 1;
        } else {
            if(is_a) blen = 0;
            blen += 1;
        }
        result = max(result, min(alen, blen) * 2);
        is_a = c == 'A';
    }

    cout << result << "\n";
}
0