結果

問題 No.1646 Avoid Palindrome
ユーザー 👑 obakyanobakyan
提出日時 2021-08-13 21:38:21
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 17:09:01
合計ジャッジ時間 1,828 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 5 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 1 ms
6,940 KB
testcase_37 AC 1 ms
6,944 KB
testcase_38 WA -
testcase_39 AC 1 ms
6,940 KB
testcase_40 AC 1 ms
6,944 KB
testcase_41 AC 1 ms
6,940 KB
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

local mod = 998244353
local mfl = math.floor
local function bmul(x, y)
  local x0, y0 = x % 31596, y % 31596
  local x1, y1 = mfl(x / 31596), mfl(y / 31596)
  return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod
end

local n = io.read("*n", "*l")
local s = io.read()
local t = {}
for i = 1, n do
  t[i] = s:sub(i, i)
end
for i = 1, n - 1 do
  if t[i] == t[i + 1] and t[i] ~= "?" then
    print(0) os.exit()
  end
end
for i = 1, n - 2 do
  if t[i] == t[i + 2] and t[i] ~= "?" then
    print(0) os.exit()
  end
end
local ret = 1
for i = 1, n do
  if i == 1 then
    if t[i] == "?" then ret = 26 end
  elseif i == 2 then
    if t[i] == "?" then ret = ret * 25 end
  else
    if t[i] == "?" then ret = bmul(ret, 24) end
  end
end
print(ret)
0