結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,732 KB
testcase_01 AC 16 ms
7,856 KB
testcase_02 WA -
testcase_03 AC 16 ms
7,824 KB
testcase_04 AC 16 ms
7,816 KB
testcase_05 AC 16 ms
7,784 KB
testcase_06 AC 16 ms
7,776 KB
testcase_07 AC 16 ms
7,804 KB
testcase_08 AC 15 ms
7,820 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1,177 ms
99,488 KB
testcase_12 AC 1,178 ms
99,520 KB
testcase_13 AC 1,180 ms
99,576 KB
testcase_14 AC 1,161 ms
93,296 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1,222 ms
76,588 KB
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 WA -
権限があれば一括ダウンロードができます

ソースコード

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())
A=[0]*N
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()
			A[j]+=C[i]+A[i]
			E[j].remove(i)
			M.add(j)
	for j in M:
		C[j]=-((C[j]+A[j])%2)
	L=M
print([-A[j],-1][C[j]])
0