結果

問題 No.1477 Lamps on Graph
ユーザー Super SolenoidSuper Solenoid
提出日時 2021-05-02 02:51:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 871 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 816,356 KB
最終ジャッジ日時 2023-09-27 16:39:18
合計ジャッジ時間 8,063 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,180 KB
testcase_01 AC 17 ms
8,116 KB
testcase_02 AC 17 ms
8,064 KB
testcase_03 AC 16 ms
8,020 KB
testcase_04 AC 17 ms
8,156 KB
testcase_05 AC 16 ms
8,092 KB
testcase_06 AC 16 ms
8,104 KB
testcase_07 AC 16 ms
8,120 KB
testcase_08 AC 16 ms
8,092 KB
testcase_09 AC 16 ms
8,108 KB
testcase_10 AC 16 ms
8,104 KB
testcase_11 AC 16 ms
8,036 KB
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(len(B)):
    L[B[i]-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 in range(N):
            if X[C[D]][C[i]] == 1:
                L[C[i]] = (L[C[i]]+1)%2
        D += 1

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