結果

問題 No.1617 Palindrome Removal
ユーザー naohSnaohS
提出日時 2021-07-22 21:37:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,389 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 89,988 KB
実行使用メモリ 5,188 KB
最終ジャッジ日時 2023-09-24 16:02:46
合計ジャッジ時間 2,341 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 24 ms
5,188 KB
testcase_02 AC 23 ms
4,380 KB
testcase_03 AC 22 ms
4,384 KB
testcase_04 AC 24 ms
5,092 KB
testcase_05 AC 19 ms
4,380 KB
testcase_06 AC 52 ms
5,092 KB
testcase_07 AC 32 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 49 ms
4,380 KB
testcase_11 AC 43 ms
4,380 KB
testcase_12 AC 53 ms
5,128 KB
testcase_13 AC 52 ms
5,072 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#include <bitset>
//#include <atcoder/all>


#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;
//using namespace atcoder;

const ll INF = 1e18;

/*
ll gcd(ll a, ll b){
	//log max(a,b)
	if (a % b == 0){
		return(b);
	}
	else{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b){
	return a * b / gcd(a, b);
}
*/
//gcd lcm
/*
class UnionFind {
public:
	vector<ll> par;

	void init(ll sz) {
		par.resize(sz, -1);
	}
	ll root(ll pos) {
		if (par[pos] == -1) return pos;
		par[pos] = root(par[pos]);
		return par[pos];
	}
	void unite(ll u, ll v) {
		u = root(u); v = root(v);
		if (u == v) return;
		par[u] = v;
	}
	bool same(ll u, ll v) {
		if (root(u) == root(v)) return true;
		return false;
	}
};
*/
typedef pair<ll, ll> P;

int main() {
	map<char, int> mp;
	string s;
	cin >> s;
	bool p = true;
	if (s.size() == 1) {
		cout << -1 << endl;
		return 0;
	}
	rep(i, (ll)s.size()) {
		mp[s[i]]++;
	}
	if (mp.size() == 1) {
		cout << 0 << endl;
		return 0;
	}
	for (ll i = 0; i < (ll)s.size() / 2; i++) {
		if (s[i] != s[s.size() - i - 1]) p = false;
	}
	if (!p) cout << s.size() << endl;
	else {
		cout << s.size() - 2 << endl;
	}
	return 0;
}


0