結果
問題 |
No.273 回文分解
|
ユーザー |
![]() |
提出日時 | 2015-08-28 22:51:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 410 bytes |
コンパイル時間 | 622 ms |
コンパイル使用メモリ | 34,784 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 11:51:14 |
合計ジャッジ時間 | 1,829 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 8 WA * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | char s[51];scanf("%s",s); | ~~~~~^~~~~~~~
ソースコード
#include <cstdio> #include <algorithm> #include <cstring> #include <cstdlib> using namespace std; //namaega184 int main(){ char s[51];scanf("%s",s); int len=strlen(s),ans=1; int cnt=0; for(int i=0;i<len;i++){ for(int j=i+1;j<len;j++){ bool f=1; for(int a=i,b=j;a<b;a++,b--){ if(s[a]!=s[b]){f=0;break;} } if(f){if(ans!=len&&j+1-i>ans)ans=j-i;} } } printf("%d\n",ans); return 0; }