結果

問題 No.1617 Palindrome Removal
ユーザー rogi52rogi52
提出日時 2022-10-03 22:47:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 2,236 ms
コンパイル使用メモリ 204,856 KB
実行使用メモリ 6,392 KB
最終ジャッジ日時 2023-08-27 20:36:16
合計ジャッジ時間 5,513 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
5,860 KB
testcase_01 AC 9 ms
6,204 KB
testcase_02 AC 9 ms
5,952 KB
testcase_03 AC 9 ms
6,148 KB
testcase_04 AC 12 ms
6,144 KB
testcase_05 AC 10 ms
5,356 KB
testcase_06 AC 6 ms
6,252 KB
testcase_07 AC 4 ms
4,820 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 30 ms
5,972 KB
testcase_11 AC 25 ms
5,716 KB
testcase_12 AC 30 ms
6,392 KB
testcase_13 AC 31 ms
6,120 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s; cin >> s;
    auto is_pal = [](string s) {
        return s == string(s.rbegin(), s.rend());
    };

    if(!is_pal(s)) {
        cout << s.size() << endl;
    } else {
        set<char> st;
        for(char c : s) st.insert(c);
        if(st.size() == 1u) {
            if(s.size() % 2 == 0) {
                cout << 0 << endl;
            } else {
                cout << -1 << endl;
            }
        } else {
            cout << s.size() - 2u << endl;
        }
    }
}
0