結果

問題 No.672 最長AB列
ユーザー sggkshio
提出日時 2019-10-03 07:47:45
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 93,532 KB
実行使用メモリ 24,448 KB
最終ジャッジ日時 2024-10-03 06:06:25
合計ジャッジ時間 4,329 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {


	string p;
	cin >> p;
	int ans = 0;

	map<int, int>t;
	for (int i = -222222; i <= 222222; i++) {
		t[i] = -1;
	}
	t[0] = 0;
	int a = 0;
	for (int i = 0; i < p.size(); i++) {
		if (p[i] == 'A')a++;
		else a--;
		if (t[a] == -1)t[a] = i;
		else {
			ans = max(ans, i - t[a]);
		}
	}


	cout << ans << endl;


	return 0;




}
0