結果

問題 No.1617 Palindrome Removal
ユーザー RubikunRubikun
提出日時 2021-07-22 21:53:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 868 bytes
コンパイル時間 1,682 ms
コンパイル使用メモリ 168,404 KB
実行使用メモリ 5,232 KB
最終ジャッジ日時 2023-09-24 16:38:44
合計ジャッジ時間 3,085 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
5,100 KB
testcase_01 AC 17 ms
5,228 KB
testcase_02 AC 17 ms
5,096 KB
testcase_03 AC 16 ms
5,232 KB
testcase_04 AC 19 ms
5,148 KB
testcase_05 AC 14 ms
4,680 KB
testcase_06 AC 38 ms
5,184 KB
testcase_07 AC 23 ms
4,436 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 35 ms
4,824 KB
testcase_11 AC 31 ms
4,944 KB
testcase_12 AC 38 ms
5,088 KB
testcase_13 AC 38 ms
5,104 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 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 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=105,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    string T=S;
    sort(all(T));
    if(T[0]==T.back()){
        if(si(S)&1) cout<<-1<<endl;
        else cout<<0<<endl;
    }else{
        T=S;
        reverse(all(T));
        if(S!=T){
            cout<<si(S)<<endl;
        }else{
            cout<<si(S)-2<<endl;
        }
    }
}
0