結果

問題 No.1617 Palindrome Removal
ユーザー ぷらぷら
提出日時 2021-07-22 21:24:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 1,976 ms
コンパイル使用メモリ 203,032 KB
実行使用メモリ 6,244 KB
最終ジャッジ日時 2023-09-24 15:28:45
合計ジャッジ時間 3,564 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
5,936 KB
testcase_01 AC 34 ms
6,244 KB
testcase_02 AC 33 ms
5,940 KB
testcase_03 AC 32 ms
5,888 KB
testcase_04 AC 35 ms
6,244 KB
testcase_05 AC 28 ms
5,676 KB
testcase_06 AC 55 ms
6,112 KB
testcase_07 AC 33 ms
4,904 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 51 ms
5,888 KB
testcase_11 AC 44 ms
5,712 KB
testcase_12 AC 54 ms
6,156 KB
testcase_13 AC 55 ms
6,108 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    string S;
    cin >> S;
    string T = S;
    reverse(T.begin(),T.end());
    string R = S;
    sort(R.begin(),R.end());
    if(S == T) {
        if(S.size() == 3 || (S.size()%2 && R.front() == R.back())) {
            cout << -1 << endl;
        }
        else if(R.front() == R.back()) {
            cout << 0 << endl;
        }
        else {
            cout << S.size()-2 << endl;
        }
    }
    else {
        cout << S.size() << endl;
    }
}
0