結果

問題 No.1617 Palindrome Removal
ユーザー re_re0101re_re0101
提出日時 2021-07-23 02:45:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,133 bytes
コンパイル時間 3,915 ms
コンパイル使用メモリ 239,748 KB
実行使用メモリ 5,268 KB
最終ジャッジ日時 2023-09-24 23:46:41
合計ジャッジ時間 5,912 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,124 KB
testcase_01 AC 6 ms
5,220 KB
testcase_02 AC 6 ms
5,188 KB
testcase_03 AC 6 ms
5,268 KB
testcase_04 AC 11 ms
5,104 KB
testcase_05 AC 9 ms
4,604 KB
testcase_06 AC 5 ms
5,224 KB
testcase_07 AC 4 ms
4,480 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 27 ms
4,944 KB
testcase_11 AC 22 ms
4,832 KB
testcase_12 AC 27 ms
5,128 KB
testcase_13 AC 28 ms
5,120 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC optimize ("O3")
// #pragma GCC target("avx512f")
// #pragma GCC optimize("unroll-loops")
// #ifndef ONLINE_JUDGE
// #define _GLIBCXX_DEBUG
// #endif
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define eb emplace_back
#define endl '\n'
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define PI 3.14159265359
const double eps = 1e-12;
const long long INF= (long long)1e18+20;
const int inf= 1010101010;
typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> Point;  // Point
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl>vvl;
typedef vector<vvl>vvvl;
typedef vector<vvvl>vvvvl;
typedef vector<vvvvl>vvvvvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
template<class T> using minpq=priority_queue<T,vector<T>,greater<T>>;
const ll MOD=1000000007LL;
// const ll MOD=998244353LL;
using mint=modint998244353;
// using mint=modint1000000007;
// using mint=modint;
const ll mod=MOD;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1,1,1,-1,-1};
vl dy={1,-1,0,0,-1,1,-1,1};

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}



typedef vector<mint>vm;
typedef vector<vm>vvm;
typedef vector<vvm>vvvm;
ll modpow(ll a, ll n,ll mod=MOD) {

    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

vector<int>divisor(int n){
  vector<int>res;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(n/i);
    }
  }
  return res;
}

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

struct edge{
    ll to;ll cost;
};

ll functional(int x){
    if(x==0)return 1;
    else return x*functional(x-1);
}

ll exp(int n,int r){
    if(r==0)return 1;
    return n*exp(n,r-1);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(12);
    /*--------------------------------*/

    string s;cin>>s;
    string t=s;
    reverse(all(t));
    ll n=s.size();
    if(s!=t){
        cout<<n<<endl;
        return 0;
    }
    set<char>st;
    for(auto c:s)st.insert(c);
    if(st.size()==1){
        if(n%2==0){
            cout<<0<<endl;
        }
        else cout<<-1<<endl;
    }
    else cout<<n-2<<endl;
    
}
0