結果

問題 No.1617 Palindrome Removal
ユーザー milanis48663220milanis48663220
提出日時 2021-07-22 22:04:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,219 bytes
コンパイル時間 1,031 ms
コンパイル使用メモリ 119,780 KB
実行使用メモリ 5,384 KB
最終ジャッジ日時 2023-09-24 17:03:34
合計ジャッジ時間 2,358 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 7 ms
4,380 KB
testcase_02 AC 8 ms
5,136 KB
testcase_03 AC 8 ms
5,084 KB
testcase_04 AC 12 ms
5,080 KB
testcase_05 AC 9 ms
4,548 KB
testcase_06 AC 32 ms
5,384 KB
testcase_07 AC 20 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 28 ms
4,832 KB
testcase_11 AC 23 ms
4,944 KB
testcase_12 AC 28 ms
5,084 KB
testcase_13 AC 29 ms
5,084 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 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 WA -
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

bool judge(string s){
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != s[n-i-1]) return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    set<char> st;
    string s; cin >> s;
    if(s.size() <= 1){
        cout << -1 << endl;
        return 0;
    }
    for(char c: s) st.insert(c);
    if(st.size() == 1){
        cout << 0 << endl;
        return 0;
    }
    if(judge(s)){
        cout << s.size()-2 << endl;
    }else{
        cout << s.size() << endl;
    }
}
0