結果

問題 No.1617 Palindrome Removal
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2021-07-31 12:38:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 437 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 163,644 KB
実行使用メモリ 5,368 KB
最終ジャッジ日時 2023-10-14 14:52:23
合計ジャッジ時間 3,034 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main () {
    string S;
    cin >> S;
    int N = S.size();
    for (int i = 0; i < N; i ++) {
        if (S[i] != S[N - i - 1]) {
            cout << N << endl;
            return 0;
        }
    }
    for (int i = 0; i < N / 2 - 1; i ++) {
        if (S[i] != S[i + 1]) {
            cout << N - 2 << endl;
            return 0;
        }
    }
    cout << (N % 2 ? -1 : 0) << endl;
}
0