結果
問題 |
No.1617 Palindrome Removal
|
ユーザー |
|
提出日時 | 2021-07-28 01:02:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 531 bytes |
コンパイル時間 | 578 ms |
コンパイル使用メモリ | 65,720 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-26 12:02:36 |
合計ジャッジ時間 | 2,283 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; string S; main() { cin>>S; bool pari=true; for(int i=0;i<S.size();i++)if(S[i]!=S[S.size()-i-1])pari=false; if(!pari) { cout<<S.size()<<endl; return 0; } bool all=true; for(int i=0;i<S.size();i++)if(S[i]!=S[0])all=false; if(all) { if(S.size()%2)cout<<-1<<endl; else cout<<0<<endl; return 0; } if(S.size()==3) { cout<<-1<<endl; return 0; } int mid=S.size()/2; int alli=-1; for(int i=0;i<mid;i++)if(S[i]!=S[0]) { alli=i; break; } cout<<S.size()-2<<endl; }