結果

問題 No.273 回文分解
ユーザー maimai
提出日時 2016-06-13 14:08:29
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 406 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-06-06 02:30:16
合計ジャッジ時間 4,138 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,160 KB
testcase_01 AC 84 ms
12,160 KB
testcase_02 AC 85 ms
12,160 KB
testcase_03 AC 83 ms
12,160 KB
testcase_04 AC 81 ms
12,160 KB
testcase_05 WA -
testcase_06 AC 82 ms
12,032 KB
testcase_07 AC 81 ms
12,288 KB
testcase_08 WA -
testcase_09 AC 83 ms
12,160 KB
testcase_10 AC 82 ms
12,160 KB
testcase_11 AC 81 ms
12,288 KB
testcase_12 AC 81 ms
12,288 KB
testcase_13 AC 83 ms
12,288 KB
testcase_14 WA -
testcase_15 AC 84 ms
12,288 KB
testcase_16 AC 84 ms
12,160 KB
testcase_17 AC 80 ms
12,160 KB
testcase_18 WA -
testcase_19 AC 80 ms
12,160 KB
testcase_20 AC 80 ms
12,160 KB
testcase_21 WA -
testcase_22 AC 81 ms
12,288 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 80 ms
12,288 KB
testcase_26 AC 119 ms
12,288 KB
testcase_27 AC 97 ms
12,544 KB
testcase_28 AC 144 ms
12,416 KB
testcase_29 AC 84 ms
12,160 KB
testcase_30 AC 82 ms
12,160 KB
testcase_31 WA -
testcase_32 AC 84 ms
12,288 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