結果

問題 No.812 Change of Class
ユーザー 👑 obakyanobakyan
提出日時 2019-05-08 23:49:52
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 5,340 KB
実行使用メモリ 43,784 KB
最終ジャッジ日時 2023-09-03 15:17:37
合計ジャッジ時間 18,229 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 291 ms
42,588 KB
testcase_01 AC 42 ms
7,720 KB
testcase_02 AC 148 ms
22,840 KB
testcase_03 AC 334 ms
43,784 KB
testcase_04 AC 292 ms
42,840 KB
testcase_05 AC 900 ms
43,200 KB
testcase_06 AC 631 ms
27,336 KB
testcase_07 AC 7 ms
4,688 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 808 ms
38,648 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 21 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 389 ms
21,024 KB
testcase_20 WA -
testcase_21 AC 315 ms
20,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 649 ms
26,020 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 62 ms
7,556 KB
testcase_30 AC 475 ms
24,080 KB
testcase_31 AC 393 ms
22,820 KB
testcase_32 AC 140 ms
11,628 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 32 ms
5,672 KB
testcase_37 AC 236 ms
14,616 KB
testcase_38 AC 11 ms
5,436 KB
testcase_39 AC 234 ms
14,804 KB
testcase_40 WA -
testcase_41 AC 9 ms
5,072 KB
testcase_42 AC 642 ms
27,004 KB
testcase_43 WA -
testcase_44 AC 366 ms
23,964 KB
testcase_45 AC 33 ms
5,544 KB
testcase_46 WA -
testcase_47 AC 391 ms
23,380 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 71 ms
7,668 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 50 ms
7,628 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 1 ms
4,376 KB
testcase_61 WA -
testcase_62 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

local ior = io.input()
local n, m = ior:read("*n", "*n")
local t = {}
for i = 1, n do t[i] = {} end
for i = 1, m do
  local a, b = ior:read("*n", "*n")
  t[a][b], t[b][a] = true, true
end
local map = {}
local q = ior:read("*n")
for i = 1, q do
  local fst = ior:read("*n")
  for j = 1, n do map[j] = -2 end
  map[fst] = -1
  local tasks = {fst}
  local tasknum = 1
  local done = 0
  local friendnum, day = 0, 0
  while(done < tasknum) do
    done = done + 1
    local curidx = tasks[done]
    for k, v in pairs(t[curidx]) do
      if(map[k] == -2) then
        map[k] = map[curidx] + 1
        friendnum, day = friendnum + 1, map[k]
        tasknum = tasknum + 1
        tasks[tasknum] = k
      end
    end
  end
  local i_d = 0
  local mult = 1
  while(mult < day) do
    i_d = i_d + 1
    mult = mult * 2
  end
  print(friendnum .. " " .. i_d)
end
0