結果

問題 No.1477 Lamps on Graph
ユーザー 小野寺健小野寺健
提出日時 2021-04-27 08:08:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 907 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 50,616 KB
最終ジャッジ日時 2023-09-20 03:55:49
合計ジャッジ時間 18,834 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,144 KB
testcase_01 AC 16 ms
8,200 KB
testcase_02 AC 16 ms
8,292 KB
testcase_03 AC 16 ms
8,176 KB
testcase_04 AC 17 ms
8,328 KB
testcase_05 AC 16 ms
8,220 KB
testcase_06 AC 17 ms
8,284 KB
testcase_07 AC 17 ms
8,180 KB
testcase_08 AC 16 ms
8,332 KB
testcase_09 AC 16 ms
8,352 KB
testcase_10 AC 16 ms
8,316 KB
testcase_11 AC 16 ms
8,296 KB
testcase_12 AC 589 ms
29,036 KB
testcase_13 AC 466 ms
29,140 KB
testcase_14 AC 654 ms
33,156 KB
testcase_15 AC 291 ms
18,024 KB
testcase_16 AC 184 ms
19,592 KB
testcase_17 AC 177 ms
18,716 KB
testcase_18 AC 469 ms
41,168 KB
testcase_19 AC 433 ms
30,872 KB
testcase_20 AC 195 ms
15,276 KB
testcase_21 AC 367 ms
35,524 KB
testcase_22 AC 138 ms
12,068 KB
testcase_23 AC 396 ms
19,944 KB
testcase_24 AC 704 ms
39,276 KB
testcase_25 AC 259 ms
17,460 KB
testcase_26 AC 611 ms
39,320 KB
testcase_27 AC 336 ms
20,280 KB
testcase_28 AC 397 ms
26,212 KB
testcase_29 AC 359 ms
23,060 KB
testcase_30 AC 197 ms
25,048 KB
testcase_31 AC 171 ms
20,956 KB
testcase_32 AC 746 ms
50,560 KB
testcase_33 AC 700 ms
50,616 KB
testcase_34 AC 613 ms
50,560 KB
testcase_35 AC 907 ms
50,060 KB
testcase_36 AC 881 ms
48,724 KB
testcase_37 AC 806 ms
46,064 KB
testcase_38 AC 836 ms
47,144 KB
testcase_39 AC 877 ms
48,084 KB
権限があれば一括ダウンロードができます

ソースコード

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 = sorted(A, key=lambda x: x.A)

op = []
for p in S:
    if p.B :
        p.B = False
        op.append(p.i+1)
        for i in p.V:
            if p.A < A[i].A:
                A[i].B = not A[i].B
            
if any([i.B for i in A]):
    print(-1)
else:
    print(len(op))
    for p in op:
        print(p)
0