結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,944 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 6 ms
6,940 KB
testcase_35 AC 1 ms
6,944 KB
testcase_36 AC 1 ms
6,940 KB
testcase_37 AC 1 ms
6,944 KB
testcase_38 AC 1 ms
6,944 KB
testcase_39 AC 1 ms
6,940 KB
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 1 ms
6,948 KB
testcase_42 AC 1 ms
6,944 KB
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
  local c = 0
  if t[i] == "?" then
    if 2 < i then
      c = c + 1
    end
    if 1 < i then
      c = c + 1
    end
    if i < n - 1 then
      if t[i + 2] ~= "?" then c = c + 1 end
    end
    if i < n then
      if t[i + 1] ~= "?" then c = c + 1 end
    end
    ret = bmul(ret, 26 - c)
  end
end
print(ret)
0