結果

問題 No.1617 Palindrome Removal
ユーザー 👑 NachiaNachia
提出日時 2021-07-22 22:07:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 75,216 KB
実行使用メモリ 6,120 KB
最終ジャッジ日時 2023-09-24 17:08:12
合計ジャッジ時間 2,102 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
5,816 KB
testcase_01 AC 22 ms
6,092 KB
testcase_02 AC 21 ms
5,896 KB
testcase_03 AC 21 ms
5,808 KB
testcase_04 AC 23 ms
6,032 KB
testcase_05 AC 18 ms
5,648 KB
testcase_06 AC 22 ms
5,056 KB
testcase_07 AC 14 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 20 ms
5,812 KB
testcase_11 AC 18 ms
5,632 KB
testcase_12 AC 22 ms
6,120 KB
testcase_13 AC 22 ms
6,084 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main(){
  string S; cin >> S;
  string rS = S;
  reverse(S.begin(),S.end());
  if(S != rS){
    cout << S.size() << "\n";
    return 0;
  }
  if(S == string(S.size(),S[0])){
    if(S.size() % 2 == 0) cout << "0\n";
    else cout << "-1\n";
    return 0;
  }
  if(S.size() == 3){
    cout << "-1\n";
    return 0;
  }
  cout << (S.size() - 2) << "\n";
  return 0;
}

0