結果

問題 No.1147 土偶Ⅱ
ユーザー 👑 obakyanobakyan
提出日時 2020-08-11 17:20:51
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 6 ms / 500 ms
コード長 1,053 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 18:07:07
合計ジャッジ時間 1,039 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 5 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 6 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n = io.read("*n")
local m = io.read("*n")
local friend = {}
local subfriend = {}
for i = 1, n - 1 do
  friend[i] = {}
  subfriend[i] = {}
  for j = i + 1, n do
    friend[i][j - i] = false
    subfriend[i][j - i] = false
  end
end
for i = 1, m do
  local a, b = io.read("*n", "*n")
  if b < a then a, b = b, a end
  friend[a][b - a] = 1
end

local ret = 0
for i = 1, n - 2 do
  for j = i + 1, n - 1 do
    for k = j + 1, n do
      if friend[i][j - i] and friend[j][k - j] and not friend[i][k - i] then
        subfriend[i][k - i] = true
      end
      if friend[i][j - i] and not friend[j][k - j] and friend[i][k - i] then
        subfriend[j][k - j] = true
      end
      if not friend[i][j - i] and friend[j][k - j] and friend[i][k - i] then
        subfriend[i][j - i] = true
      end
    end
  end
end
for i = 1, n - 2 do
  for j = i + 1, n - 1 do
    for k = j + 1, n do
      if not subfriend[i][j - i]
      and not subfriend[j][k - j]
      and not subfriend[i][k - i] then
        ret = ret + 1
      end
    end
  end
end
print(ret)
0