結果
問題 |
No.588 空白と回文
|
ユーザー |
![]() |
提出日時 | 2016-05-07 20:26:38 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 954 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 20,480 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-05 10:23:20 |
合計ジャッジ時間 | 1,027 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:58:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 58 | scanf("%s", s); | ^~~~~~~~~~~~~~
ソースコード
// A is for "Ant" #include <stdio.h> #define S_MAX 1000 char s[S_MAX + 1]; int max(int a, int b){ return (a > b) ? a : b; } int odd(){ char *first, *last; char *center; int answer = 0; for (center = s; *center; center++) { int maybe_ans = -1; first = last = center; while (first - s >= 0 && *last) { if (*first == *last) maybe_ans += 2; first--; last++; } if (maybe_ans > answer) { answer = maybe_ans; } } return answer; } int even(){ char *first, *last; char *centeright; int answer = 0; for (centeright = s + 1; *centeright; centeright++) { int maybe_ans = 0; first = centeright - 1, last = centeright; while (first - s >= 0 && *last) { if (*first == *last) maybe_ans += 2; first--; last++; } if (maybe_ans > answer) { answer = maybe_ans; } } return answer; } int solve(){ return max(even(), odd()); } int main(void){ scanf("%s", s); printf("%d\n", solve()); return 0; }