結果

問題 No.2205 Lights Out on Christmas Tree
ユーザー 👑 p-adicp-adic
提出日時 2023-05-31 17:11:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 366 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 99,064 KB
最終ジャッジ日時 2023-08-28 01:34:18
合計ジャッジ時間 38,241 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,824 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 16 ms
7,852 KB
testcase_03 AC 16 ms
7,936 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,764 KB
testcase_06 WA -
testcase_07 AC 16 ms
7,796 KB
testcase_08 AC 15 ms
7,760 KB
testcase_09 AC 16 ms
7,848 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1,191 ms
99,028 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 1,225 ms
90,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

I,R=input,range
def S(n):
	return int(n)-1
def J():
	return map(S,I().split())
N=int(I())
E=[set()for i in R(N)]
for i in R(N-1):
	a,b=J()
	E[a].add(b),E[b].add(a)
C=list(J())
L=set()
for i in R(N):
	if len(E[i])<2:L.add(i)
while len(L):
	M=set()
	for i in L:
		if len(E[i]):
			j=E[i].pop()
			C[j]+=C[i]
			E[j].remove(i)
			M.add(j)
	L=M
print([-C[j],-1][C[j]%2])
0