結果
| 問題 |
No.273 回文分解
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-13 14:08:29 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 406 bytes |
| コンパイル時間 | 417 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-12-23 13:16:41 |
| 合計ジャッジ時間 | 4,947 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 23 WA * 9 |
コンパイルメッセージ
Syntax OK
ソースコード
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)