結果
問題 | No.1477 Lamps on Graph |
ユーザー |
![]() |
提出日時 | 2021-04-16 20:18:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 415 ms / 2,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 203 ms |
コンパイル使用メモリ | 82,332 KB |
実行使用メモリ | 112,008 KB |
最終ジャッジ日時 | 2024-07-02 22:17:40 |
合計ジャッジ時間 | 10,192 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
n,m=map(int,input().split()) a=list(map(int,input().split())) path=[[] for _ in range(n)] for i in range(m): c,d=map(int,input().split()) if a[c-1]<a[d-1]:path[c-1].append(d-1) if a[d-1]<a[c-1]:path[d-1].append(c-1) seen=[False]*n k=int(input()) b=list(map(int,input().split())) for i in b:seen[i-1]=True num=[[a[_],_] for _ in range(n)] num.sort(key=lambda x: x[0]) ans=[] for i in range(n): ind=num[i][1] if seen[ind]: ans.append(ind+1) for j in range(len(path[ind])): if seen[path[ind][j]]:seen[path[ind][j]]=False else:seen[path[ind][j]]=True print(len(ans)) for i in ans:print(i)