結果

問題 No.1617 Palindrome Removal
ユーザー riano
提出日時 2021-07-22 21:26:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 644 bytes
コンパイル時間 1,876 ms
コンパイル使用メモリ 172,496 KB
実行使用メモリ 5,424 KB
最終ジャッジ日時 2024-07-17 16:19:10
合計ジャッジ時間 3,081 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Pr pair<ll,ll>
#define Tp tuple<ll,ll,ll>
using Graph = vector<vector<int>>;

const ll mod = 998244353;

int main() {
    string S; cin >> S;
    int N = S.size();
    string T = S;
    reverse(T.begin(),T.end());
    if(S!=T){
        cout << N << endl; return 0;
    }
    set<char> ss;
    rep(i,N){
        if(N%2==1&&i==(N/2)) continue;
        ss.insert(S[i]);
    }
    if(ss.size()>1){
        cout << N-2 << endl; return 0;
    }
    if(N%2==0){
        cout << 0 << endl; return 0;
    }
    cout << -1 << endl;
}
0