結果

問題 No.1617 Palindrome Removal
ユーザー SSRS
提出日時 2021-07-22 21:25:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 592 bytes
コンパイル時間 1,645 ms
コンパイル使用メモリ 168,252 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-17 16:17:05
合計ジャッジ時間 3,414 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  string S2 = S;
  reverse(S2.begin(), S2.end());
  if (S != S2){
    cout << S.size() << endl;
  } else if (S.size() == 1){
    cout << -1 << endl;
  } else {
    S.pop_back();
    S.pop_back();
    S2.erase(S2.begin());
    S2.erase(S2.begin());
    if (S != S2){
      cout << S.size() << endl;
    } else {
      for (int i = 0; i < S.size(); i++){
        assert(S[i] == S[0]);
      }
      if (S.size() % 2 == 0){
        cout << 0 << endl;
      } else {
        cout << -1 << endl;
      }
    }
  }
}
0