結果

問題 No.1477 Lamps on Graph
ユーザー 小野寺健小野寺健
提出日時 2021-04-26 17:46:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,227 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 54,988 KB
最終ジャッジ日時 2023-09-18 12:25:38
合計ジャッジ時間 16,154 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,376 KB
testcase_01 AC 16 ms
8,308 KB
testcase_02 AC 16 ms
8,328 KB
testcase_03 AC 15 ms
8,444 KB
testcase_04 AC 15 ms
8,380 KB
testcase_05 WA -
testcase_06 AC 16 ms
8,364 KB
testcase_07 AC 16 ms
8,416 KB
testcase_08 AC 15 ms
8,336 KB
testcase_09 AC 15 ms
8,420 KB
testcase_10 RE -
testcase_11 AC 15 ms
8,308 KB
testcase_12 AC 610 ms
28,796 KB
testcase_13 AC 561 ms
29,332 KB
testcase_14 AC 770 ms
32,352 KB
testcase_15 AC 333 ms
17,712 KB
testcase_16 AC 232 ms
19,180 KB
testcase_17 AC 203 ms
18,676 KB
testcase_18 AC 1,036 ms
41,328 KB
testcase_19 AC 588 ms
29,856 KB
testcase_20 AC 202 ms
15,124 KB
testcase_21 AC 724 ms
35,628 KB
testcase_22 AC 167 ms
12,272 KB
testcase_23 AC 463 ms
20,156 KB
testcase_24 AC 902 ms
38,716 KB
testcase_25 AC 295 ms
17,412 KB
testcase_26 AC 946 ms
39,276 KB
testcase_27 AC 386 ms
20,216 KB
testcase_28 AC 537 ms
25,628 KB
testcase_29 AC 410 ms
22,696 KB
testcase_30 AC 349 ms
25,124 KB
testcase_31 AC 251 ms
20,368 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

class Peek:
    def __init__(self, i, A):
        self.i = i
        self.A = A
        self.V = []
        self.B = False
    def __str__(self):
        return str(self.i) + ":" + str(self.A) + "," + str(self.B) + "," + str(self.V)
        
N, M = map(int, input().split())

A = []
for i, a in enumerate(list(map(int, input().split()))):
    A.append(Peek(i, a))
    
for _ in range(M):
    u, v = map(int, input().split())
    A[u-1].V.append(v-1)
    A[v-1].V.append(u-1)
    
K = int(input())
for b in list(map(int, input().split())):
    A[b-1].B = True

S = []
for P in A:
    noInput = True
    for i in P.V:
        if P.A > A[i].A:
            noInput = False
            break
    if noInput:
        S.append(P)
        
op = []
while len(S) > 0:
    n = S.pop(0)
    b = n.B
    if b:
        n.B = False
        op.append(n.i + 1)
    for i in n.V:
        m = A[i]
        m.V.remove(n.i)
        if b:
            m.B =  not m.B
        noInput = True
        for i in m.V:
            if m.A > A[i].A:
                noInput = False
                break
        if noInput:
            S.append(m)
            
if any([i.B for i in A]):
    print(-1)
else:
    print(len(op))
    for p in op:
        print(p)
0