結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,136 KB
testcase_01 AC 16 ms
8,200 KB
testcase_02 AC 16 ms
8,108 KB
testcase_03 AC 16 ms
8,076 KB
testcase_04 AC 16 ms
8,052 KB
testcase_05 AC 15 ms
8,076 KB
testcase_06 AC 16 ms
8,136 KB
testcase_07 AC 16 ms
8,024 KB
testcase_08 AC 16 ms
8,168 KB
testcase_09 AC 16 ms
8,176 KB
testcase_10 AC 16 ms
8,120 KB
testcase_11 AC 16 ms
8,116 KB
testcase_12 AC 815 ms
28,620 KB
testcase_13 AC 604 ms
29,348 KB
testcase_14 AC 889 ms
32,216 KB
testcase_15 AC 434 ms
17,904 KB
testcase_16 AC 250 ms
19,212 KB
testcase_17 AC 219 ms
18,652 KB
testcase_18 AC 1,121 ms
41,416 KB
testcase_19 AC 639 ms
29,956 KB
testcase_20 AC 252 ms
15,252 KB
testcase_21 AC 797 ms
35,536 KB
testcase_22 AC 259 ms
12,260 KB
testcase_23 AC 571 ms
19,920 KB
testcase_24 AC 970 ms
38,680 KB
testcase_25 AC 341 ms
17,040 KB
testcase_26 AC 986 ms
39,392 KB
testcase_27 AC 481 ms
19,948 KB
testcase_28 AC 554 ms
25,760 KB
testcase_29 AC 459 ms
22,700 KB
testcase_30 AC 356 ms
25,128 KB
testcase_31 AC 256 ms
20,428 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 j in m.V:
            if m.A > A[j].A:
                noInput = False
            elif m.A == A[j].A:
                m.V.remove(j)
        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