結果
問題 |
No.1617 Palindrome Removal
|
ユーザー |
![]() |
提出日時 | 2021-07-29 18:46:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 562 bytes |
コンパイル時間 | 544 ms |
コンパイル使用メモリ | 67,288 KB |
最終ジャッジ日時 | 2025-01-23 10:11:11 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 WA * 2 |
ソースコード
#include<iostream> #include<string> using namespace std; #define rep(i,s,n) for (int i=s;i<n;i++) int main(){ string S;cin>>S; int n=S.length(); int bef=S[0]; bool kaibun=true,same=true; rep(i,0,n/2){ if(S[i]!=S[n-1-i]){ kaibun=same=false; break; } if(bef!=S[i] || bef!=S[n-1-i]){ same=false; } bef=S[i]; } if((n%2)&&bef!=S[n/2])same=false; if(same){ if(n>1) cout<<0; else cout<<-1; }else if(kaibun){ if(n>3) cout<<n-2; else cout<<-1; }else{ cout<<n; }cout<<endl; }