結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
nii
|
| 提出日時 | 2018-05-12 20:14:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,288 bytes |
| コンパイル時間 | 1,006 ms |
| コンパイル使用メモリ | 91,432 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-28 09:42:05 |
| 合計ジャッジ時間 | 1,754 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 6 |
ソースコード
#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;
}
nii