結果

問題 No.812 Change of Class
ユーザー 👑 obakyanobakyan
提出日時 2019-05-08 23:53:27
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 850 ms / 4,000 ms
コード長 851 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 5,292 KB
実行使用メモリ 43,960 KB
最終ジャッジ日時 2023-09-03 15:24:50
合計ジャッジ時間 16,600 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 280 ms
42,588 KB
testcase_01 AC 42 ms
7,640 KB
testcase_02 AC 150 ms
22,800 KB
testcase_03 AC 320 ms
43,960 KB
testcase_04 AC 309 ms
42,760 KB
testcase_05 AC 850 ms
43,056 KB
testcase_06 AC 622 ms
27,352 KB
testcase_07 AC 7 ms
4,632 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 724 ms
37,700 KB
testcase_10 AC 794 ms
38,580 KB
testcase_11 AC 30 ms
9,624 KB
testcase_12 AC 429 ms
22,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 438 ms
24,116 KB
testcase_16 AC 21 ms
4,380 KB
testcase_17 AC 432 ms
22,552 KB
testcase_18 AC 268 ms
20,620 KB
testcase_19 AC 306 ms
20,880 KB
testcase_20 AC 697 ms
40,432 KB
testcase_21 AC 249 ms
20,320 KB
testcase_22 AC 103 ms
11,312 KB
testcase_23 AC 16 ms
4,380 KB
testcase_24 AC 28 ms
5,476 KB
testcase_25 AC 81 ms
8,004 KB
testcase_26 AC 500 ms
26,088 KB
testcase_27 AC 439 ms
25,360 KB
testcase_28 AC 280 ms
20,488 KB
testcase_29 AC 63 ms
7,544 KB
testcase_30 AC 400 ms
24,108 KB
testcase_31 AC 326 ms
22,816 KB
testcase_32 AC 126 ms
11,624 KB
testcase_33 AC 394 ms
23,496 KB
testcase_34 AC 25 ms
5,088 KB
testcase_35 AC 69 ms
7,508 KB
testcase_36 AC 33 ms
6,104 KB
testcase_37 AC 196 ms
14,568 KB
testcase_38 AC 10 ms
5,492 KB
testcase_39 AC 207 ms
14,772 KB
testcase_40 AC 46 ms
6,892 KB
testcase_41 AC 9 ms
5,192 KB
testcase_42 AC 458 ms
26,900 KB
testcase_43 AC 51 ms
8,972 KB
testcase_44 AC 310 ms
24,020 KB
testcase_45 AC 33 ms
5,556 KB
testcase_46 AC 48 ms
8,720 KB
testcase_47 AC 323 ms
23,352 KB
testcase_48 AC 328 ms
21,812 KB
testcase_49 AC 89 ms
8,396 KB
testcase_50 AC 5 ms
4,388 KB
testcase_51 AC 71 ms
7,720 KB
testcase_52 AC 139 ms
12,872 KB
testcase_53 AC 58 ms
7,760 KB
testcase_54 AC 50 ms
7,616 KB
testcase_55 AC 191 ms
23,812 KB
testcase_56 AC 247 ms
41,392 KB
testcase_57 AC 259 ms
41,848 KB
testcase_58 AC 131 ms
22,172 KB
testcase_59 AC 287 ms
42,556 KB
testcase_60 AC 1 ms
4,380 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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] = -1 end
  map[fst] = 0
  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] == -1) 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