結果
問題 | No.241 出席番号(1) |
ユーザー |
👑 |
提出日時 | 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 |
ソースコード
local n = io.read("*n")local t = {}local ans = {}local ngcnt = {}local idx = {}for i = 1, n doans[i] = 1000000007idx[i] = ingcnt[i] = 0t[i] = {}for j = 1, n dot[i][j] = trueendendfor i = 1, n dolocal a = io.read("*n") + 1if a <= n thent[i][a] = falsengcnt[a] = ngcnt[a] + 1endendtable.sort(idx, function(a, b) return ngcnt[a] < ngcnt[b] end)if ngcnt[idx[n]] == n thenprint(-1)os.exit()endlocal function debug()print("---")for i = 1, n dofor j = 1, n doio.write(t[i][j] and 1 or 0)io.write(j == n and "\n" or " ")endendendfor i = 1, n do-- debug()local num = idx[#idx]for iuser = 1, n doif t[iuser][num] thenans[iuser] = num - 1for j = 1, n doif t[iuser][j] thenngcnt[j] = ngcnt[j] + 1endt[j][num] = falset[iuser][j] = falseendbreakendendif i ~= n thentable.remove(idx)table.sort(idx, function(a, b) return ngcnt[a] < ngcnt[b] end)endendprint(table.concat(ans, "\n"))