結果
| 問題 | No.588 空白と回文 | 
| コンテスト | |
| ユーザー |  ugis_prog | 
| 提出日時 | 2018-06-09 22:43:35 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,001 bytes | 
| コンパイル時間 | 590 ms | 
| コンパイル使用メモリ | 67,092 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-30 13:05:20 | 
| 合計ジャッジ時間 | 1,455 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 8 WA * 17 | 
ソースコード
#include<iostream>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans = -1;
    for(int i=0;i<s.size();i++){
        stack<char> st;
        int count = 0;
        string front = "";
        for(int j=i;j<s.size();j++){
            if(s[j] != s[i]){
                st.push('@');
            }
            else st.push(s[j]);
        }
        
        for(int j = s.size()-1;s[j] != s[i];j--){
            st.pop();
        }
        for(int j=i;!st.empty();j++){
            if(st.top() == s[i] || st.top() == '@'){
                front += st.top();
                if(st.top() == '@') count++;
                st.pop();
            }
            else break;
        }
        string back = front;
        reverse(front.begin(),front.end());
        if(back != front) back = "";
        if(count == 1) count--;
        count = back.size()-count;
        ans = max(ans,count);
        
    }
    cout<<ans<<endl;
}
            
            
            
        