結果
問題 | No.1169 Row and Column and Diagonal |
ユーザー |
👑 |
提出日時 | 2020-08-14 21:43:09 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 830 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 6,948 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-10-10 14:47:01 |
合計ジャッジ時間 | 1,226 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
local n = io.read("*n") local rowrem = {} local colrem = {} for i = 1, n do rowrem[i] = {} colrem[i] = {} for j = 1, n do rowrem[i][j] = true colrem[i][j] = true end end local ret = {} for i = 1, n do ret[i] = {} for j = 1, i - 1 do ret[i][j] = 0 end ret[i][i] = i rowrem[i][i] = false colrem[i][i] = false local cand = i for j = 1, i - 1 do while true do if rowrem[i][cand] and colrem[j][cand] then ret[i][j] = cand rowrem[i][cand] = false colrem[j][cand] = false rowrem[j][cand] = false colrem[i][cand] = false break end cand = cand + 1 if n < cand then cand = cand - n end end end end for i = 1, n do for j = i + 1, n do ret[i][j] = ret[j][i] end end for i = 1, n do print(table.concat(ret[i], " ")) end