結果

問題 No.273 回文分解
ユーザー maimai
提出日時 2016-06-13 14:08:29
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 406 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 11,220 KB
実行使用メモリ 15,428 KB
最終ジャッジ日時 2023-08-25 01:31:10
合計ジャッジ時間 4,340 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
15,036 KB
testcase_01 AC 73 ms
15,124 KB
testcase_02 AC 74 ms
15,300 KB
testcase_03 AC 76 ms
15,148 KB
testcase_04 AC 72 ms
15,040 KB
testcase_05 WA -
testcase_06 AC 72 ms
15,148 KB
testcase_07 AC 72 ms
15,172 KB
testcase_08 WA -
testcase_09 AC 74 ms
15,128 KB
testcase_10 AC 74 ms
15,264 KB
testcase_11 AC 76 ms
15,348 KB
testcase_12 AC 71 ms
15,156 KB
testcase_13 AC 73 ms
15,348 KB
testcase_14 WA -
testcase_15 AC 75 ms
15,160 KB
testcase_16 AC 72 ms
15,160 KB
testcase_17 AC 73 ms
15,264 KB
testcase_18 WA -
testcase_19 AC 76 ms
15,044 KB
testcase_20 AC 73 ms
15,168 KB
testcase_21 WA -
testcase_22 AC 74 ms
15,124 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 72 ms
15,272 KB
testcase_26 AC 107 ms
15,268 KB
testcase_27 AC 86 ms
15,204 KB
testcase_28 AC 130 ms
15,388 KB
testcase_29 AC 75 ms
15,344 KB
testcase_30 AC 72 ms
15,352 KB
testcase_31 WA -
testcase_32 AC 73 ms
15,296 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

def calc(str,beg)
    return str.size if iskb(str)&&beg
    max=1
    (str.size-2).downto(1){|i|
        if iskb(str[0..i])
            u = [i+1,calc(str[i+1,99],true)].max
            max=u if max<u
        end
    }
    return max
end

p calc(gets.chomp,false)
0