結果

問題 No.672 最長AB列
ユーザー focusfocus
提出日時 2018-05-22 15:00:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 362 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 83,856 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2024-06-28 15:44:25
合計ジャッジ時間 1,873 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using ll = long long ;
using namespace std;
int main(){
	string str;
	map<ll,ll> m;
	ll ans=0,p=0;
	cin >> str;
	ll len = str.size();
	m[0] = -1;
	for(ll i=0;i<len;i++){
		if(str[i]=='A')	p++;
		else	p--;
		if(m.count(p)) ans=(ans,i-m[p]);
		else m[p]=i;
	}
	cout << ans << endl;
	return 0;
}
0