結果

問題 No.479 頂点は要らない
ユーザー 👑 obakyanobakyan
提出日時 2019-06-04 07:42:52
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 183 ms / 1,500 ms
コード長 752 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 27,356 KB
最終ジャッジ日時 2023-10-17 23:36:48
合計ジャッジ時間 4,498 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 183 ms
26,256 KB
testcase_27 AC 182 ms
26,256 KB
testcase_28 AC 117 ms
27,356 KB
testcase_29 AC 92 ms
15,640 KB
testcase_30 AC 94 ms
15,640 KB
testcase_31 AC 93 ms
15,640 KB
testcase_32 AC 92 ms
15,640 KB
testcase_33 AC 140 ms
16,432 KB
testcase_34 AC 149 ms
16,696 KB
testcase_35 AC 105 ms
9,428 KB
testcase_36 AC 46 ms
5,332 KB
testcase_37 AC 147 ms
18,280 KB
testcase_38 AC 116 ms
14,584 KB
testcase_39 AC 93 ms
13,528 KB
testcase_40 AC 119 ms
17,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, m = io.read("*n", "*n")
local line = {}
for i = 1, n do
  line[i] = {}
  line[i].l = {}
  line[i].score = -1
end
for i = 1, m do
  local a, b = io.read("*n", "*n")
  a, b = a + 1, b + 1
  table.insert(line[a].l, b)
  table.insert(line[b].l, a)
end

local function getmax(curmax)
  for i = curmax, 1, -1 do
    if line[i].score == -1 then
      return i
    end
  end
  return 0
end

local curmax = n

while 0 < curmax do
  line[curmax].score = 0
  for i = 1, #line[curmax].l do
    local dstidx = line[curmax].l[i]
    line[dstidx].score = 1
  end
  curmax = getmax(curmax)
end
local max1 = 1
for i = n, 1, -1 do
  if line[i].score == 1 then
    max1 = i
    break
  end
end
for i = max1, 1, -1 do
  io.write(line[i].score)
end
io.write("\n")
0