結果
問題 | No.1617 Palindrome Removal |
ユーザー | riano |
提出日時 | 2021-07-22 21:30:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 1,573 ms |
コンパイル使用メモリ | 172,568 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-17 16:34:55 |
合計ジャッジ時間 | 2,912 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define Pr pair<ll,ll> #define Tp tuple<ll,ll,ll> using Graph = vector<vector<int>>; const ll mod = 998244353; int main() { string S; cin >> S; int N = S.size(); string T = S; reverse(T.begin(),T.end()); if(S!=T){ cout << N << endl; return 0; } set<char> ss; rep(i,N){ //if(N%2==1&&i==(N/2)) continue; ss.insert(S[i]); } if(ss.size()>1&&N>=4){ cout << N-2 << endl; return 0; } if(N%2==0){ cout << 0 << endl; return 0; } cout << -1 << endl; }