結果
問題 | No.1169 Row and Column and Diagonal |
ユーザー | 👑 obakyan |
提出日時 | 2020-08-14 21:43:09 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 830 bytes |
コンパイル時間 | 314 ms |
コンパイル使用メモリ | 6,816 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-04-18 21:20:39 |
合計ジャッジ時間 | 1,259 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 5 ms
5,376 KB |
testcase_07 | AC | 8 ms
5,376 KB |
testcase_08 | AC | 12 ms
6,144 KB |
testcase_09 | AC | 17 ms
7,168 KB |
testcase_10 | AC | 25 ms
9,088 KB |
testcase_11 | AC | 27 ms
9,472 KB |
testcase_12 | AC | 29 ms
9,600 KB |
testcase_13 | AC | 28 ms
9,728 KB |
testcase_14 | AC | 28 ms
9,856 KB |
ソースコード
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