結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
15,296 KB
testcase_01 AC 18 ms
8,112 KB
testcase_02 AC 16 ms
8,080 KB
testcase_03 AC 16 ms
8,092 KB
testcase_04 AC 16 ms
8,204 KB
testcase_05 AC 16 ms
8,180 KB
testcase_06 AC 16 ms
8,104 KB
testcase_07 AC 16 ms
8,080 KB
testcase_08 AC 17 ms
8,092 KB
testcase_09 AC 16 ms
8,056 KB
testcase_10 AC 16 ms
8,204 KB
testcase_11 AC 16 ms
8,104 KB
testcase_12 AC 811 ms
28,664 KB
testcase_13 AC 683 ms
29,288 KB
testcase_14 AC 993 ms
32,144 KB
testcase_15 AC 456 ms
17,800 KB
testcase_16 AC 262 ms
19,276 KB
testcase_17 AC 233 ms
18,660 KB
testcase_18 AC 1,117 ms
41,368 KB
testcase_19 AC 658 ms
29,852 KB
testcase_20 AC 251 ms
15,188 KB
testcase_21 AC 756 ms
35,668 KB
testcase_22 AC 270 ms
12,184 KB
testcase_23 AC 650 ms
19,964 KB
testcase_24 AC 1,080 ms
38,656 KB
testcase_25 AC 378 ms
17,196 KB
testcase_26 AC 1,030 ms
39,252 KB
testcase_27 AC 523 ms
20,048 KB
testcase_28 AC 639 ms
25,712 KB
testcase_29 AC 544 ms
22,728 KB
testcase_30 AC 360 ms
25,160 KB
testcase_31 AC 269 ms
20,540 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
            elif m.A == A[i].A:
                m.V.remove(i)
        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