結果

問題 No.1477 Lamps on Graph
ユーザー Super SolenoidSuper Solenoid
提出日時 2021-05-02 03:42:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 816,552 KB
最終ジャッジ日時 2023-09-27 17:39:58
合計ジャッジ時間 6,320 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 MLE -
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] = [0]*N

L = [0]*N

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

for i in range(K):
    L[B[i]-1] = 1

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

Y = [0]*N
D = 0

S = 0

del A, B, V
while sum(L) > 0:
    if D == N:
        break
    E = C[D]
    if L[K] == 0:
        D += 1
    else:
        L[K] = 0
        Y[S]=K+1
        for i in range(N):
            if X[K][i] == 1:
                L[i] = (L[i]+1)%2
        D += 1
        S += 1

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