結果
問題 | No.1034 テスターのふっぴーさん |
ユーザー |
👑 |
提出日時 | 2020-04-24 22:29:59 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,494 bytes |
コンパイル時間 | 67 ms |
コンパイル使用メモリ | 6,688 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 03:11:38 |
合計ジャッジ時間 | 983 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
local mfl, mce = math.floor, math.ceillocal mab = math.abslocal mmi, mma = math.min, math.maxlocal function llprint(llnumber)local str = tostring(llnumber):gsub("LL", "")print(str)endlocal q = io.read("*n")for iq = 1, q dolocal n, i, j = io.read("*n", "*n", "*n")n = n - 1if n % 2 == 0 thenlocal center = mfl(n / 2)local radius = mma(mab(i - center), mab(j - center))local tot = (1LL + n) * (1LL + n)if radius == 0 thenllprint(tot - 1LL)elselocal v = (radius * 2LL - 1LL) * (radius * 2LL - 1LL)local line = radius * 2LLif center - radius == i and center + radius ~= j then-- top leftlocal diff_from_topleft = j - (center - radius)local z = v + line * 4LL - diff_from_topleftllprint(tot - z)elseif center + radius == j and center + radius ~= i then-- right toplocal diff_from_righttop = i - (center - radius)local z = v + line * 3LL - diff_from_righttopllprint(tot - z)elseif center + radius == i and center - radius ~= j then-- bottom rightlocal diff_from_bottomright = center + radius - jlocal z = v + line * 2LL - diff_from_bottomrightllprint(tot - z)else-- left bottomlocal diff_from_leftbottom = center + radius - ilocal z = v + line - diff_from_leftbottomllprint(tot - z)endendelse -- n % 2 == 1local hn = mfl((n + 1) / 2)local radius = i < hn and hn - i or i - (hn - 1)dolocal tmp = j < hn and hn - j or j - (hn - 1)radius = mma(radius, tmp)endlocal rl, rr = hn - radius, hn - 1 + radiuslocal tot = (1LL + n) * (1LL + n)local v = (radius * 2LL - 2LL) * (radius * 2LL - 2LL)local line = radius * 2LL - 1LLif rl == i and rr ~= j then-- top leftlocal diff_from_topleft = j - rllocal z = v + line * 4LL - diff_from_topleftllprint(tot - z)elseif rr == j and rr ~= i then-- right toplocal diff_from_righttop = i - rllocal z = v + line * 3LL - diff_from_righttopllprint(tot - z)elseif rr == i and rl ~= j then-- bottom rightlocal diff_from_bottomright = rr - jlocal z = v + line * 2LL - diff_from_bottomrightllprint(tot - z)else-- left bottomlocal diff_from_leftbottom = rr - ilocal z = v + line - diff_from_leftbottomllprint(tot - z)endendend