結果
| 問題 |
No.2073 Concon Substrings (Swap Version)
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-09-22 12:53:57 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 832 bytes |
| コンパイル時間 | 237 ms |
| コンパイル使用メモリ | 7,076 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-22 04:49:54 |
| 合計ジャッジ時間 | 1,995 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 17 WA * 20 |
ソースコード
local mmi, mma = math.min, math.max
local n = io.read("*n", "*l")
local rawn = n
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])
local ret = a + b + c
local need = 0
if 0 < b + c then
need = a + 1 + b + c
end
if n < need then
ret = ret - (need - n)
end
print(ret)