結果

問題 No.1477 Lamps on Graph
ユーザー Super SolenoidSuper Solenoid
提出日時 2021-05-02 03:16:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 852 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,840 KB
実行使用メモリ 41,720 KB
最終ジャッジ日時 2023-09-27 17:10:56
合計ジャッジ時間 5,137 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,276 KB
testcase_01 AC 14 ms
8,336 KB
testcase_02 AC 14 ms
8,184 KB
testcase_03 AC 15 ms
8,344 KB
testcase_04 AC 15 ms
8,268 KB
testcase_05 AC 15 ms
8,332 KB
testcase_06 AC 14 ms
8,340 KB
testcase_07 AC 15 ms
8,188 KB
testcase_08 AC 15 ms
8,288 KB
testcase_09 AC 16 ms
7,832 KB
testcase_10 AC 16 ms
8,280 KB
testcase_11 AC 15 ms
7,888 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = [int(s) for s in input().split()]
V = [[int(i)-1 for i in input().split()] for m in range(M)]

K = int(input())
B = [int(s) for s in input().split()]

X = [0]*N

for i in range(N):
    X[i] = []

L = [0]*N

for i in range(M):
    a = V[i][0]
    b = V[i][1]
    if A[a] < A[b]:
        X[a].append(b)
    else:
        if A[b] < A[a]:
            X[b].append(a)

for j in range(len(B)):
    L[B[j]-1] = 1

A, C = (list(t) for t in zip(*sorted(zip(A, list(range(N))))))

Y = []
D = 0

while sum(L) > 0:
    if D == N:
        break
    if L[C[D]] == 0:
        D += 1
    else:
        L[C[D]] = 0
        Y.append(C[D]+1)
        for i, item in enumerate(X[C[D]]):
            L[item] = (L[item]+1)%2
        D += 1

if D == N+1:
    print(-1)
else:
    print(len(Y))
    for i in range(len(Y)):
        print(Y[i])
0