結果

問題 No.672 最長AB列
ユーザー focusfocus
提出日時 2018-05-22 14:59:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 344 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 80,628 KB
実行使用メモリ 15,852 KB
最終ジャッジ日時 2023-09-11 01:12:46
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 100 ms
15,852 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 73 ms
9,596 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#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] = 0;
	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