結果

問題 No.241 出席番号(1)
ユーザー 👑 obakyan
提出日時 2020-04-23 22:41:00
言語 Lua
(LuaJit 2.1.1734355927)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,077 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 6,952 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 01:45:29
合計ジャッジ時間 1,320 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

local n = io.read("*n")
local t = {}
local ans = {}
local ngcnt = {}
local idx = {}
for i = 1, n do
ans[i] = 1000000007
idx[i] = i
ngcnt[i] = 0
t[i] = {}
for j = 1, n do
t[i][j] = true
end
end
for i = 1, n do
local a = io.read("*n") + 1
if a <= n then
t[i][a] = false
ngcnt[a] = ngcnt[a] + 1
end
end
table.sort(idx, function(a, b) return ngcnt[a] < ngcnt[b] end)
if ngcnt[idx[n]] == n then
print(-1)
os.exit()
end
local function debug()
print("---")
for i = 1, n do
for j = 1, n do
io.write(t[i][j] and 1 or 0)
io.write(j == n and "\n" or " ")
end
end
end
for i = 1, n do
-- debug()
local num = idx[#idx]
for iuser = 1, n do
if t[iuser][num] then
ans[iuser] = num - 1
for j = 1, n do
if t[iuser][j] then
ngcnt[j] = ngcnt[j] + 1
end
t[j][num] = false
t[iuser][j] = false
end
break
end
end
if i ~= n then
table.remove(idx)
table.sort(idx, function(a, b) return ngcnt[a] < ngcnt[b] end)
end
end
print(table.concat(ans, "\n"))
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0