結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー 👑 obakyan
提出日時 2022-09-22 12:48:09
言語 Lua
(LuaJit 2.1.1734355927)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 5,632 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-22 04:48:34
合計ジャッジ時間 1,710 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 25 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma = math.min, math.max
local n = io.read("*n", "*l")
n = n * 3
local s = io.read()
local x, y, z = {0,0,0},{0,0,0},{0,0,0}
for i = 1, n do
  local si = s:sub(i, i)
  if si == "c" then
    if i % 3 == 1 then x[1] = x[1] + 1
    elseif i % 3 == 2 then x[2] = x[2] + 1
    else x[3] = x[3] + 1
    end
  elseif si == "o" then
    if i % 3 == 2 then y[1] = y[1] + 1
    elseif i % 3 == 0 then y[2] = y[2] + 1
    else y[3] = y[3] + 1
    end
  elseif si == "n" then
    if i % 3 == 0 then z[1] = z[1] + 1
    elseif i % 3 == 1 then z[2] = z[2] + 1
    else z[3] = z[3] + 1
    end
  end
end
local a, b, c = mmi(x[1],y[1],z[1]), mmi(x[2],y[2],z[2]), mmi(x[3],y[3],z[3])
if b * 3 == n then
  print(b - 1)
  os.exit()
end
if c * 3 == n then
  print(c - 1)
  os.exit()
end
print(a + b + c)
0