結果
問題 | No.672 最長AB列 |
ユーザー | ninoinui |
提出日時 | 2020-03-09 20:57:54 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 508 bytes |
コンパイル時間 | 1,661 ms |
コンパイル使用メモリ | 165,036 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-04-26 17:20:35 |
合計ジャッジ時間 | 2,542 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | WA | - |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 6 ms
5,376 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 7 ms
5,376 KB |
testcase_18 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N = S.size(); vector<int> V(N); S.insert(S.size(), " "); for (int i = 0, cnt = 1; i < N; i++) { if (S.at(i) != S.at(i + 1)) V.at(i) = cnt, cnt = 1; else cnt++; } for (int i = N - 1; i >= 0; i--) { if (!V.at(i)) V.at(i) = V.at(i + 1); } int ans = 0; for (int i = 0; i + 1 < N; i++) { if (V.at(i) != V.at(i + 1)) ans = max(ans, min(V.at(i), V.at(i + 1)) * 2); } cout << ans << "\n"; }