結果

問題 No.672 最長AB列
ユーザー niinii
提出日時 2018-05-12 20:14:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,288 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 89,144 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-10 18:31:07
合計ジャッジ時間 2,602 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
//
int main(){
	string S;
	cin>>S;
	int N=S.size();
	stack<char> st;
	int now=0;
	VE V;
	FOR(i,0,N){
		if(st.empty()){
			st.push(S[i]);
		}else if(st.top()==S[i]){
			st.push(S[i]);
		}else{
			now=0;
			while(i<N&&!st.empty()&&st.top()!=S[i]){
				st.pop();
				i++;
				now+=2;
			}
			i--;
			if(st.empty()&&!V.empty()){
				int num=V.back();
				V.PPB();
				V.PB(num+now);
			}else{
				V.PB(now);
			}
		}
	}
	if(V.empty()){
		cout<<0<<endl;
	}else{
		sort(V.begin(),V.end());
		cout<<V.back()<<endl;
	}
	return 0;
}
0