結果

問題 No.1477 Lamps on Graph
ユーザー 👑 obakyanobakyan
提出日時 2021-08-11 20:21:53
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 19,004 KB
最終ジャッジ日時 2023-10-25 22:26:59
合計ジャッジ時間 7,564 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 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 2 ms
4,348 KB
testcase_12 AC 112 ms
9,952 KB
testcase_13 AC 106 ms
9,584 KB
testcase_14 AC 136 ms
10,620 KB
testcase_15 AC 57 ms
5,808 KB
testcase_16 AC 55 ms
7,688 KB
testcase_17 AC 49 ms
6,504 KB
testcase_18 AC 154 ms
15,308 KB
testcase_19 AC 114 ms
10,308 KB
testcase_20 AC 38 ms
4,668 KB
testcase_21 AC 127 ms
13,656 KB
testcase_22 AC 23 ms
4,348 KB
testcase_23 AC 71 ms
6,412 KB
testcase_24 AC 164 ms
12,056 KB
testcase_25 AC 51 ms
5,148 KB
testcase_26 AC 164 ms
14,908 KB
testcase_27 AC 68 ms
6,476 KB
testcase_28 AC 97 ms
9,444 KB
testcase_29 AC 83 ms
7,188 KB
testcase_30 AC 75 ms
9,244 KB
testcase_31 AC 59 ms
8,088 KB
testcase_32 AC 225 ms
19,004 KB
testcase_33 AC 216 ms
17,544 KB
testcase_34 AC 170 ms
15,992 KB
testcase_35 AC 227 ms
17,188 KB
testcase_36 AC 216 ms
17,088 KB
testcase_37 AC 198 ms
16,544 KB
testcase_38 AC 207 ms
17,032 KB
testcase_39 AC 214 ms
17,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, m = io.read("*n", "*n")
local a = {}
local aidx = {}
for i = 1, n do
  a[i] = io.read("*n")
  aidx[i] = i
end
table.sort(aidx, function(x, y) return a[x] < a[y] end)
local edge = {}
for i = 1, n do
  edge[i] = {}
end
for i = 1, m do
  local x, y = io.read("*n", "*n")
  if a[x] < a[y] then
    table.insert(edge[x], y)
  elseif a[y] < a[x] then
    table.insert(edge[y], x)
  end
end
local flag = {}
for i = 1, n do
  flag[i] = false
end
local k = io.read("*n")
for i = 1, k do
  local z = io.read("*n")
  flag[z] = true
end
local ret = {}
for ia = 1, n do
  local i = aidx[ia]
  if flag[i] then
    table.insert(ret, i)
    for j = 1, #edge[i] do
      local dst = edge[i][j]
      flag[dst] = not flag[dst]
    end
  end
end
print(#ret)
print(table.concat(ret, "\n"))
0