結果
問題 | No.1617 Palindrome Removal |
ユーザー |
![]() |
提出日時 | 2021-07-22 21:26:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 3,889 ms |
コンパイル使用メモリ | 256,196 KB |
最終ジャッジ日時 | 2025-01-23 06:05:21 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#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 1000000001bool 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{if(n==3){cout<<-1<<endl;}else{cout<<n-2<<endl;}}}else{if(S.size()==1)cout<<0<<endl;else cout<<n-2<<endl;}return 0;}