結果

問題 No.1617 Palindrome Removal
ユーザー maguroflymagurofly
提出日時 2021-07-22 21:25:31
言語 Ruby
(3.3.0)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 210 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 11,256 KB
実行使用メモリ 69,024 KB
最終ジャッジ日時 2023-09-24 15:30:45
合計ジャッジ時間 7,033 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 335 ms
66,128 KB
testcase_01 AC 344 ms
69,024 KB
testcase_02 AC 335 ms
66,564 KB
testcase_03 AC 337 ms
66,340 KB
testcase_04 AC 353 ms
68,844 KB
testcase_05 AC 309 ms
58,920 KB
testcase_06 AC 359 ms
68,944 KB
testcase_07 AC 266 ms
49,268 KB
testcase_08 AC 81 ms
15,088 KB
testcase_09 AC 80 ms
15,264 KB
testcase_10 AC 345 ms
65,428 KB
testcase_11 AC 323 ms
59,132 KB
testcase_12 AC 373 ms
68,992 KB
testcase_13 AC 360 ms
68,924 KB
testcase_14 AC 80 ms
15,304 KB
testcase_15 AC 80 ms
15,144 KB
testcase_16 AC 80 ms
15,316 KB
testcase_17 AC 80 ms
15,196 KB
testcase_18 AC 80 ms
15,092 KB
testcase_19 AC 80 ms
15,148 KB
testcase_20 AC 80 ms
15,164 KB
testcase_21 AC 80 ms
15,252 KB
testcase_22 AC 78 ms
15,292 KB
testcase_23 AC 79 ms
15,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:12: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

S = gets.chomp
T = S.chars.tally
if S != S.reverse
    puts S.size
elsif T.size >= 2
    if S.size == 3
        puts -1
    else
        puts S.size - 2
    end
elsif S.size.odd?
    puts -1
else
    puts 0
end
0