結果
問題 | No.1034 テスターのふっぴーさん |
ユーザー | 👑 obakyan |
提出日時 | 2020-04-24 22:29:59 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
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 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 1 ms
5,248 KB |
testcase_11 | AC | 1 ms
5,248 KB |
testcase_12 | AC | 1 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | AC | 1 ms
5,248 KB |
testcase_17 | AC | 1 ms
5,248 KB |
testcase_18 | AC | 1 ms
5,248 KB |
testcase_19 | AC | 2 ms
5,248 KB |
testcase_20 | AC | 2 ms
5,248 KB |
testcase_21 | AC | 2 ms
5,248 KB |
testcase_22 | AC | 2 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 2 ms
5,248 KB |
testcase_25 | AC | 2 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 2 ms
5,248 KB |
testcase_29 | AC | 2 ms
5,248 KB |
ソースコード
local mfl, mce = math.floor, math.ceil local mab = math.abs local mmi, mma = math.min, math.max local function llprint(llnumber) local str = tostring(llnumber):gsub("LL", "") print(str) end local q = io.read("*n") for iq = 1, q do local n, i, j = io.read("*n", "*n", "*n") n = n - 1 if n % 2 == 0 then local center = mfl(n / 2) local radius = mma(mab(i - center), mab(j - center)) local tot = (1LL + n) * (1LL + n) if radius == 0 then llprint(tot - 1LL) else local v = (radius * 2LL - 1LL) * (radius * 2LL - 1LL) local line = radius * 2LL if center - radius == i and center + radius ~= j then -- top left local diff_from_topleft = j - (center - radius) local z = v + line * 4LL - diff_from_topleft llprint(tot - z) elseif center + radius == j and center + radius ~= i then -- right top local diff_from_righttop = i - (center - radius) local z = v + line * 3LL - diff_from_righttop llprint(tot - z) elseif center + radius == i and center - radius ~= j then -- bottom right local diff_from_bottomright = center + radius - j local z = v + line * 2LL - diff_from_bottomright llprint(tot - z) else -- left bottom local diff_from_leftbottom = center + radius - i local z = v + line - diff_from_leftbottom llprint(tot - z) end end else -- n % 2 == 1 local hn = mfl((n + 1) / 2) local radius = i < hn and hn - i or i - (hn - 1) do local tmp = j < hn and hn - j or j - (hn - 1) radius = mma(radius, tmp) end local rl, rr = hn - radius, hn - 1 + radius local tot = (1LL + n) * (1LL + n) local v = (radius * 2LL - 2LL) * (radius * 2LL - 2LL) local line = radius * 2LL - 1LL if rl == i and rr ~= j then -- top left local diff_from_topleft = j - rl local z = v + line * 4LL - diff_from_topleft llprint(tot - z) elseif rr == j and rr ~= i then -- right top local diff_from_righttop = i - rl local z = v + line * 3LL - diff_from_righttop llprint(tot - z) elseif rr == i and rl ~= j then -- bottom right local diff_from_bottomright = rr - j local z = v + line * 2LL - diff_from_bottomright llprint(tot - z) else -- left bottom local diff_from_leftbottom = rr - i local z = v + line - diff_from_leftbottom llprint(tot - z) end end end