結果

問題 No.1617 Palindrome Removal
ユーザー nok0
提出日時 2021-07-06 18:19:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 305 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 195,892 KB
最終ジャッジ日時 2025-01-22 17:50:34
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int k = count(s.begin(), s.end(), s[0]);
	if(n == k)
		puts(n & 1 ? "-1" : "0");
	else {
		if(s == string{s.rbegin(), s.rend()})
			cout << (n > 3 ? n - 2 : -1) << endl;
		else
			cout << n << endl;
	}
}
0