結果
問題 | No.1477 Lamps on Graph |
ユーザー | Super Solenoid |
提出日時 | 2021-05-02 04:28:02 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 850 ms / 2,000 ms |
コード長 | 576 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 44,048 KB |
最終ジャッジ日時 | 2024-07-20 12:54:11 |
合計ジャッジ時間 | 17,234 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
N, M = map(int, input().split()) A = [int(s) for s in input().split()] X = [[] for _ in range(N)] for i in range(M): U, V = map(int, input().split()) U -= 1 V -= 1 if A[U] < A[V]: X[U].append(V) if A[V] < A[U]: X[V].append(U) K = int(input()) B = [int(s) for s in input().split()] L = [False]*N for i in B: L[i - 1] = True F = sorted([(A[i], i) for i in range(N)]) Y = [] for _, i in F: if L[i]: Y.append(i+1) for j in X[i]: L[j] = not L[j] print(len(Y)) for i in range(len(Y)): print(Y[i])