結果
問題 |
No.1617 Palindrome Removal
|
ユーザー |
👑 |
提出日時 | 2021-07-22 21:25:22 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
RE
|
実行時間 | - |
コード長 | 411 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-17 16:16:15 |
合計ジャッジ時間 | 1,172 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 4 |
other | RE * 20 |
ソースコード
local s = io.read() local allsame = true local n = #s for i = 2, n do if s:byte(1) ~= s:byte(i) then allsame = false break end end local pali = true for i = 1, n do local j = n + 1 - j if i < j then if s:byte(i) ~= s:byte(j) then pali = false break end else break end end if allsame then print(n % 2 == 0 and 0 or -1) else if pali then print(n - 2) else print(n) end end