結果
| 問題 |
No.1617 Palindrome Removal
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-07-22 21:24:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 588 bytes |
| コンパイル時間 | 4,618 ms |
| コンパイル使用メモリ | 255,152 KB |
| 最終ジャッジ日時 | 2025-01-23 06:03:44 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 WA * 2 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
bool check(string s){
string t(s.rbegin(),s.rend());
return s==t;
}
int main(){
string s;
cin>>s;
set<char> S;
rep(i,s.size())S.insert(s[i]);
int n = s.size();
if(!check(s)){
cout<<n<<endl;
return 0;
}
if(n%2==1){
if(S.size()==1)cout<<-1<<endl;
else cout<<n-2<<endl;
}
else{
if(S.size()==1)cout<<0<<endl;
else cout<<n-2<<endl;
}
return 0;
}
沙耶花