結果
問題 | No.1617 Palindrome Removal |
ユーザー |
|
提出日時 | 2021-07-22 21:23:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 458 bytes |
コンパイル時間 | 2,202 ms |
コンパイル使用メモリ | 199,340 KB |
最終ジャッジ日時 | 2025-01-23 06:01:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ string s; cin>>s; set<char> st; for(char c:s)st.insert(c); if(st.size()==1){ if(s.size()%2==0)puts("0"); else puts("-1"); } else{ string t=s; reverse(t.begin(),t.end()); if(s==t){ if(s.size()==3)puts("-1"); else cout<<s.size()-2<<endl; } else cout<<s.size()<<endl; } }