結果

問題 No.1477 Lamps on Graph
ユーザー 小野寺健小野寺健
提出日時 2021-04-26 17:55:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,263 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 55,192 KB
最終ジャッジ日時 2023-09-18 12:36:56
合計ジャッジ時間 16,195 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,356 KB
testcase_01 AC 16 ms
8,056 KB
testcase_02 AC 16 ms
8,156 KB
testcase_03 AC 15 ms
8,104 KB
testcase_04 AC 16 ms
8,104 KB
testcase_05 AC 16 ms
8,112 KB
testcase_06 AC 15 ms
7,972 KB
testcase_07 AC 15 ms
8,064 KB
testcase_08 AC 16 ms
8,092 KB
testcase_09 AC 16 ms
7,976 KB
testcase_10 AC 16 ms
8,032 KB
testcase_11 AC 16 ms
8,040 KB
testcase_12 AC 673 ms
28,704 KB
testcase_13 AC 597 ms
29,380 KB
testcase_14 AC 786 ms
32,200 KB
testcase_15 AC 370 ms
17,664 KB
testcase_16 AC 239 ms
19,152 KB
testcase_17 AC 225 ms
18,504 KB
testcase_18 AC 975 ms
41,276 KB
testcase_19 AC 605 ms
29,776 KB
testcase_20 AC 217 ms
15,148 KB
testcase_21 AC 713 ms
35,628 KB
testcase_22 AC 182 ms
12,088 KB
testcase_23 AC 490 ms
19,880 KB
testcase_24 AC 882 ms
38,712 KB
testcase_25 AC 298 ms
17,028 KB
testcase_26 AC 927 ms
39,316 KB
testcase_27 AC 413 ms
19,892 KB
testcase_28 AC 527 ms
25,576 KB
testcase_29 AC 439 ms
22,684 KB
testcase_30 AC 391 ms
24,960 KB
testcase_31 AC 250 ms
20,372 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
        elif P.A == A[i].A:
            P.V.remove(i)
    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