結果
問題 | No.1617 Palindrome Removal |
ユーザー |
👑 |
提出日時 | 2021-07-22 21:25:52 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
WA
|
実行時間 | - |
コード長 | 411 bytes |
コンパイル時間 | 37 ms |
コンパイル使用メモリ | 6,940 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-17 16:17:06 |
合計ジャッジ時間 | 1,023 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 WA * 2 |
ソースコード
local s = io.read()local allsame = truelocal n = #sfor i = 2, n doif s:byte(1) ~= s:byte(i) thenallsame = false breakendendlocal pali = truefor i = 1, n dolocal j = n + 1 - iif i < j thenif s:byte(i) ~= s:byte(j) then pali = false break endelsebreakendendif allsame thenprint(n % 2 == 0 and 0 or -1)elseif pali thenprint(n - 2)elseprint(n)endend