結果
問題 |
No.672 最長AB列
|
ユーザー |
|
提出日時 | 2022-10-17 04:34:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 581 bytes |
コンパイル時間 | 628 ms |
コンパイル使用メモリ | 70,656 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 21:09:08 |
合計ジャッジ時間 | 1,490 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 9 |
ソースコード
#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; }