結果

問題 No.1617 Palindrome Removal
ユーザー hiikunZhiikunZ
提出日時 2021-07-22 21:54:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,304 bytes
コンパイル時間 2,191 ms
コンパイル使用メモリ 201,688 KB
実行使用メモリ 5,236 KB
最終ジャッジ日時 2023-09-24 16:39:57
合計ジャッジ時間 3,745 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const ll MAX = 5000000000000000000;
const ld PI = 3.14159265358979;
const ll MOD = 0;//2024948111;
ld dotorad(ld K){return PI * K / 180.0;}
ld radtodo(ld K){return K * 180.0 / PI;}
mt19937 mt;
void randinit(){srand((unsigned)time(NULL));mt = mt19937(rand());}
int main(){
    string S;
    cin >> S;
    ll N = S.size();
    for(ll i = 0;i < N;i++){
        if(S[i] != S[N - 1 - i]){
            cout << N << endl;
            return 0;
        }
    }
    if(N % 2 == 0){
        vector<ll> A(500,0);
        for(ll i = 0;i < N / 2;i++){
            if(A[S[i]] - 'a' == 1){
                cout << N - 2 << endl;
                return 0;
            }
            A[S[i] - 'a'] = 1;
        }
        cout << 0 << endl;
    }
    else{
        ll m = N / 2;
        vector<ll> A(500,0);
        for(ll i = 0;i < m;i++){
            if(A[S[i]] - 'a' == 1){
                cout << N - 2 << endl;
                return 0;
            }
            A[S[i] - 'a'] = 1;
        }
        if(N <= 3){
            cout << -1 << endl;
            return 0;
        }
        if(S[0] == S[m]){
            cout << -1 << endl;
            return 0;
        }
        cout << N - 2 << endl;
        return 0;
    }
}
0