結果

問題 No.672 最長AB列
ユーザー phspls
提出日時 2020-04-21 00:06:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 537 bytes
コンパイル時間 1,590 ms
コンパイル使用メモリ 166,544 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-06 09:37:23
合計ジャッジ時間 2,632 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 9
権限があれば一括ダウンロードができます

ソースコード

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