結果

問題 No.1617 Palindrome Removal
ユーザー a01sa01to
提出日時 2025-08-27 00:46:57
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 2,983 ms
コンパイル使用メモリ 280,180 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-27 00:47:02
合計ジャッジ時間 4,970 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  string s;
  cin >> s;
  {
    string t = s;
    reverse(t.begin(), t.end());
    if (s != t) {
      cout << s.size() << '\n';
      return 0;
    }
  }
  set<char> st(s.begin(), s.end());
  if (st.size() == 1) {
    cout << (s.size() % 2 == 0 ? 0 : -1) << '\n';
  }
  else {
    cout << (s.size() == 3 ? -1 : s.size() - 2) << '\n';
  }
  return 0;
}
0