結果

問題 No.2205 Lights Out on Christmas Tree
ユーザー gr1msl3ygr1msl3y
提出日時 2023-06-06 20:50:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 153,236 KB
最終ジャッジ日時 2023-08-28 10:49:19
合計ジャッジ時間 13,695 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,176 KB
testcase_01 AC 70 ms
71,120 KB
testcase_02 AC 69 ms
71,184 KB
testcase_03 AC 70 ms
71,364 KB
testcase_04 AC 70 ms
71,460 KB
testcase_05 AC 70 ms
71,248 KB
testcase_06 AC 71 ms
71,460 KB
testcase_07 AC 70 ms
71,376 KB
testcase_08 AC 70 ms
71,388 KB
testcase_09 AC 70 ms
71,416 KB
testcase_10 AC 69 ms
71,480 KB
testcase_11 AC 312 ms
151,104 KB
testcase_12 AC 307 ms
151,600 KB
testcase_13 AC 313 ms
150,344 KB
testcase_14 AC 283 ms
153,236 KB
testcase_15 AC 273 ms
147,448 KB
testcase_16 WA -
testcase_17 AC 214 ms
123,436 KB
testcase_18 AC 71 ms
71,472 KB
testcase_19 AC 284 ms
146,392 KB
testcase_20 AC 278 ms
147,540 KB
testcase_21 AC 287 ms
147,492 KB
testcase_22 AC 286 ms
144,980 KB
testcase_23 AC 283 ms
147,560 KB
testcase_24 AC 285 ms
145,572 KB
testcase_25 AC 279 ms
147,664 KB
testcase_26 AC 284 ms
147,624 KB
testcase_27 WA -
testcase_28 AC 285 ms
143,656 KB
testcase_29 AC 286 ms
132,588 KB
testcase_30 AC 287 ms
147,572 KB
testcase_31 AC 284 ms
149,468 KB
testcase_32 AC 285 ms
145,524 KB
testcase_33 AC 285 ms
145,436 KB
testcase_34 AC 279 ms
147,448 KB
testcase_35 AC 285 ms
147,868 KB
testcase_36 WA -
testcase_37 AC 282 ms
147,688 KB
testcase_38 AC 284 ms
147,440 KB
testcase_39 AC 290 ms
146,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

C = [0]+list(map(int, input().split()))
parent = [-1]*(N+1)
task = [1]
for v in task:
    for u in graph[v]:
        if parent[u] == -1:
            task.append(u)
            parent[u] = v

ans = 0
for v in task[1:][::-1]:
    if C[v]:
        continue
    C[parent[v]] ^= 1
    C[v] = 1
    ans += 1

print(ans if C[1] else -1)
0