結果

問題 No.1477 Lamps on Graph
ユーザー vwxyzvwxyz
提出日時 2023-11-23 05:45:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,390 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 34,948 KB
最終ジャッジ日時 2023-11-23 05:45:28
合計ジャッジ時間 13,857 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
11,136 KB
testcase_01 AC 36 ms
11,136 KB
testcase_02 AC 36 ms
11,136 KB
testcase_03 AC 36 ms
11,264 KB
testcase_04 AC 36 ms
11,264 KB
testcase_05 AC 37 ms
11,136 KB
testcase_06 AC 35 ms
11,136 KB
testcase_07 AC 35 ms
11,136 KB
testcase_08 AC 35 ms
11,136 KB
testcase_09 AC 34 ms
11,136 KB
testcase_10 WA -
testcase_11 AC 39 ms
11,136 KB
testcase_12 AC 254 ms
23,264 KB
testcase_13 AC 264 ms
22,920 KB
testcase_14 AC 321 ms
24,908 KB
testcase_15 AC 153 ms
16,752 KB
testcase_16 AC 106 ms
18,288 KB
testcase_17 AC 105 ms
17,648 KB
testcase_18 AC 298 ms
28,836 KB
testcase_19 AC 217 ms
23,984 KB
testcase_20 AC 114 ms
14,976 KB
testcase_21 AC 236 ms
26,280 KB
testcase_22 AC 95 ms
13,184 KB
testcase_23 AC 193 ms
17,740 KB
testcase_24 AC 393 ms
27,988 KB
testcase_25 AC 142 ms
16,244 KB
testcase_26 AC 303 ms
28,848 KB
testcase_27 AC 194 ms
18,364 KB
testcase_28 AC 191 ms
22,204 KB
testcase_29 AC 188 ms
19,548 KB
testcase_30 AC 156 ms
20,604 KB
testcase_31 AC 119 ms
18,292 KB
testcase_32 AC 476 ms
34,292 KB
testcase_33 AC 439 ms
34,420 KB
testcase_34 WA -
testcase_35 AC 458 ms
34,388 KB
testcase_36 AC 431 ms
34,444 KB
testcase_37 AC 400 ms
34,420 KB
testcase_38 AC 392 ms
34,392 KB
testcase_39 AC 417 ms
34,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
#sys.set_int_max_str_digits(10**9)

N,M=map(int,readline().split())
A=list(map(int,readline().split()))
graph=[[] for x in range(N)]
for m in range(M):
    u,v=map(int,readline().split())
    u-=1;v-=1
    if A[u]>A[v]:
        u,v=v,u
    graph[u].append(v)
dp=[0]*N
ans_lst=[]
K=int(readline())
for b in map(int,readline().split()):
    b-=1
    dp[b]=1
for x in sorted([x for x in range(N)],key=lambda x:A[x]):
    if dp[x]:
        dp[x]^=1
        for y in graph[x]:
            dp[y]^=1
        ans_lst.append(x)
if all(dp[x]==0 for x in range(N)):
    print(len(ans_lst))
    for m in ans_lst:
        print(m+1)
else:
    print(-1)
0