結果

問題 No.672 最長AB列
ユーザー focusfocus
提出日時 2018-05-22 15:10:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 381 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 83,300 KB
実行使用メモリ 15,912 KB
最終ジャッジ日時 2023-09-11 01:13:47
合計ジャッジ時間 1,995 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 99 ms
15,912 KB
testcase_10 AC 75 ms
9,668 KB
testcase_11 AC 72 ms
9,604 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 73 ms
9,668 KB
testcase_18 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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