結果

問題 No.1617 Palindrome Removal
ユーザー SSRS
提出日時 2021-07-22 21:23:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 490 bytes
コンパイル時間 1,766 ms
コンパイル使用メモリ 167,444 KB
実行使用メモリ 5,428 KB
最終ジャッジ日時 2024-07-17 16:10:51
合計ジャッジ時間 3,044 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 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 if (S.size() % 2 == 0){
      cout << 0 << endl;
    } else {
      cout << -1 << endl;
    }
  }
}
0