結果
問題 |
No.672 最長AB列
|
ユーザー |
|
提出日時 | 2021-11-17 13:49:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 331 bytes |
コンパイル時間 | 2,069 ms |
コンパイル使用メモリ | 200,524 KB |
最終ジャッジ日時 | 2025-01-25 18:58:38 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) int main() { string s; cin >> s; int n = s.size(); int a = 0, ans = 0; map<int, int> mp; mp[0] = -1; rep(i,n) { a += s[i] == 'A' ? 1 : -1; if (mp.count(a))ans = max(ans, i - mp[a]); mp[a] = i; } cout << ans << "\n"; return 0; }