結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-05-11 00:04:51 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 655 bytes |
| コンパイル時間 | 3,486 ms |
| コンパイル使用メモリ | 279,284 KB |
| 実行使用メモリ | 18,896 KB |
| 最終ジャッジ日時 | 2025-05-11 00:04:56 |
| 合計ジャッジ時間 | 4,287 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
string s;
cin >> s;
vector cnt(2 * s.size() + 1, vector<int>(0));
int now = s.size();
cnt[now].push_back(-1);
rep(i, s.size()) {
(s[i] == 'A' ? now++ : now--);
cnt[now].push_back(i);
}
int ans = 0;
for (auto&& v : cnt) {
if (v.size() < 2) continue;
ans = max(ans, v.back() - v.front());
}
cout << ans << '\n';
return 0;
}
a01sa01to