結果

問題 No.273 回文分解
ユーザー mai
提出日時 2016-06-13 14:19:48
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 303 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-12-23 13:16:46
合計ジャッジ時間 4,492 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 23 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def iskb(str)
    n=str.size
    return true if n==1
    0.upto(n/2){|i|
        return false if str[i]!=str[n-i-1]
    }
    return true
end

s = gets.chomp
n = s.size
max=2
0.upto(n-2){|i|
    i.upto(n-1){|j|
        next if i==0 && j==n-1
        max=j-i+1 if iskb(s[i..j]) && max<j-i+1
    }
}
p max
0