結果

問題 No.672 最長AB列
ユーザー sawfishsawfish
提出日時 2022-10-17 04:34:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 581 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 70,816 KB
実行使用メモリ 4,548 KB
最終ジャッジ日時 2023-09-10 05:34:48
合計ジャッジ時間 1,784 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 6 ms
4,384 KB
testcase_10 AC 5 ms
4,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
4,380 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;
using LL = long long;
using ULL = unsigned long long;

constexpr int INF = 1 << 30;
constexpr LL INFL = 1L << 62;
//constexpr int MOD = 998244353;

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

    vector<int> AB{1};
    for (int i = 1; i < S.size(); i++) {
        if (S[i] != S[i - 1]) {
            AB.push_back(1);
        } else {
            AB.back()++;
        }
    }

    int ans = 0;
    for (int i = 0; i < AB.size() - 1; i++) {
        ans = max(ans, min(AB[i], AB[i + 1]) * 2);
    }

    cout << ans << endl;
}
0