結果
| 問題 | No.1617 Palindrome Removal | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-07-22 21:25:31 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 396 ms / 2,000 ms | 
| コード長 | 210 bytes | 
| コンパイル時間 | 71 ms | 
| コンパイル使用メモリ | 7,424 KB | 
| 実行使用メモリ | 67,072 KB | 
| 最終ジャッジ日時 | 2024-07-17 16:16:49 | 
| 合計ジャッジ時間 | 6,860 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 20 | 
コンパイルメッセージ
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
ソースコード
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
            
            
            
        