結果

問題 No.1477 Lamps on Graph
ユーザー okapinokapin
提出日時 2021-04-16 20:31:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 47,620 KB
最終ジャッジ日時 2023-09-15 21:23:30
合計ジャッジ時間 16,636 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,144 KB
testcase_01 AC 16 ms
8,020 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 16 ms
8,092 KB
testcase_05 WA -
testcase_06 AC 17 ms
8,056 KB
testcase_07 AC 16 ms
8,176 KB
testcase_08 AC 16 ms
8,072 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 16 ms
7,912 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 617 ms
47,552 KB
testcase_33 WA -
testcase_34 AC 556 ms
47,572 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
a=list(map(int,input().split()))
g=[[] for _ in range(n)]
for i in range(m):
    u,v=map(int,input().split())
    g[u-1].append(v-1)
    g[v-1].append(u-1)
k=int(input())
b=list(map(int,input().split()))

arr=[0]*n
for i in range(n):
    arr[i]=(i,a[i])
arr=sorted(arr,key=lambda x: x[1])

on=[0]*n
for j in range(k):
    on[b[j]-1]=1


ans=[]
for i in range(n):
    p=arr[i][0]
    if on[p]==0:
        continue
    for c in g[p]:
        if on[c]:
            if a[c]>a[p]:
                on[c]=0
    ans.append(p+1)
print(len(ans))
print(*ans,sep='\n')
0