結果
| 問題 |
No.1170 Never Want to Walk
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2021-06-13 23:48:31 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,006 bytes |
| コンパイル時間 | 373 ms |
| コンパイル使用メモリ | 6,820 KB |
| 実行使用メモリ | 9,088 KB |
| 最終ジャッジ日時 | 2024-12-23 14:54:31 |
| 合計ジャッジ時間 | 4,008 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 WA * 15 |
ソースコード
local mmi, mma = math.min, math.max
local n, a, b = io.read("*n", "*n", "*n")
local x = {}
local parent = {}
local pend = {}
for i = 1, n do
x[i] = io.read("*n")
parent[i] = i
pend[i] = 0
end
local left, right = 1, 0
for i = 1, n do
while left <= n do
if x[left] - x[i] < a then
left = left + 1
else
break
end
end
while right < n do
if x[right + 1] - x[i] <= b then
right = right + 1
else
break
end
end
-- print(i, left, right)
if left <= right then
if left ~= parent[left] then
local p = parent[left]
parent[i] = p
for j = pend[p] + 1, right do
parent[j] = p
end
pend[p] = right
else
local p = parent[i]
for j = left, right do
parent[j] = p
end
pend[p] = right
end
end
end
-- print(table.concat(parent, " "))
local g = {}
for i = 1, n do
local p = parent[i]
if g[p] then g[p] = g[p] + 1 else g[p] = 1 end
end
for i = 1, n do
print(g[parent[i]])
end