結果

問題 No.588 空白と回文
ユーザー 0w10w1
提出日時 2017-11-05 15:05:26
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 308 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-05-03 05:32:49
合計ジャッジ時間 4,963 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
12,160 KB
testcase_01 AC 91 ms
12,160 KB
testcase_02 AC 91 ms
12,288 KB
testcase_03 WA -
testcase_04 AC 91 ms
12,288 KB
testcase_05 AC 93 ms
12,160 KB
testcase_06 AC 98 ms
12,032 KB
testcase_07 WA -
testcase_08 AC 92 ms
12,032 KB
testcase_09 AC 94 ms
12,160 KB
testcase_10 AC 91 ms
12,288 KB
testcase_11 WA -
testcase_12 AC 293 ms
12,288 KB
testcase_13 WA -
testcase_14 AC 93 ms
12,032 KB
testcase_15 WA -
testcase_16 AC 93 ms
12,288 KB
testcase_17 AC 221 ms
12,544 KB
testcase_18 AC 90 ms
12,160 KB
testcase_19 AC 89 ms
12,160 KB
testcase_20 AC 292 ms
12,160 KB
testcase_21 AC 249 ms
12,160 KB
testcase_22 AC 290 ms
12,416 KB
testcase_23 AC 208 ms
12,416 KB
testcase_24 AC 89 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

S = gets.chop

ans = 0

S.size.times do |i|
  c = 1
  1.upto([i, S.size - i - 1].min) do |j|
    c += S[i - j] == S[i + j] ? 2 : 0
  end
  ans = [ans, c].max
end

S.size.times do |i|
  c = 0
  1.upto([i, S.size - i].min) do |j|
    c += S[i - j - 1] == S[i + j] ? 2 : 0
  end
  ans = [ans, c].max
end

p ans
0