結果
問題 | No.1477 Lamps on Graph |
ユーザー |
![]() |
提出日時 | 2021-04-16 21:30:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 807 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 39,588 KB |
最終ジャッジ日時 | 2024-07-03 00:52:12 |
合計ジャッジ時間 | 11,984 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 WA * 15 TLE * 1 -- * 17 |
ソースコード
N,M=map(int,input().split())A=[0]+list(map(int,input().split()))E=[[] for i in range(N+1)]for i in range(M):u,v=map(int,input().split())if A[u]>A[v]:E[v].append(u)elif A[v]>A[u]:E[u].append(v)K=int(input())B=list(map(int,input().split()))LIGHT=[0]*(N+1)for b in B:LIGHT[b]=1DEGIN=[0]*(N+1)for i in range(1,N+1):for k in E[i]:DEGIN[k]+=1Q=[]ANS=[]for i in range(1,N+1):if DEGIN[i]==0:if LIGHT[i]==1:Q.append((i,1))ANS.append(i)else:Q.append((i,0))while Q:#print(Q)now,t=Q.pop()for to in E[now]:if t!=LIGHT[to]:ANS.append(to)Q.append((to,LIGHT[to]))print(len(ANS))print("\n".join(map(str,ANS)))