用户输出
23
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#103658 | #1432. [L2-1] 树木加固 | Accepted | 100 | 5748 ms | 194728 K | Python 3 / 635 B | Austin4.5 | 2024-04-11 20:44:27 |
class TreeNode():
val = None
left = None
right = None
def __init__(self, val):
self.val = val
def __repr__(self):
return 'TreeNode:' + str(self.val)
def it(t):
global s
if t.left is not None:
it(t.left)
it(t.right)
s += abs(t.left.val) + abs(t.right.val)
t.val += t.left.val + t.right.val
n = int(input())
t = []
for i in range(n):
t.extend(map(int, input().split()))
m = [TreeNode(t[i]) for i in range((1<<n) - 1)]
for i in range((1<<n-1)-1):
m[i].left = m[2*i+1]
m[i].right = m[2*i+2]
s = 0
it(m[0])
print(s)
用户输出
11887
系统信息
Exited with return code 0
用户输出
8158
系统信息
Exited with return code 0
8
114
-808 -998
-826 -984 316 9
-510 -266 401 -830 860 388 -560 -918
67 -319 -972 -451 -30 267 -
<1036 bytes omitted>
用户输出
272319
系统信息
Exited with return code 0
8
-822
-975 757
984 -999 989 -284
81 981 -308 998 -596 395 -673 -738
889 -780 -353 448 -788 -492
<1037 bytes omitted>
用户输出
255014
系统信息
Exited with return code 0
8
-646
-115 -20
-448 712 -920 618
-28 -977 317 160 -621 970 -994 -326
-738 446 -103 -190 218 958
<1037 bytes omitted>
用户输出
273545
系统信息
Exited with return code 0
8
-26
-528 -860
-580 687 -902 680
-997 -939 858 -150 43 977 -605 813
-732 128 28 -68 693 -525 31
<1035 bytes omitted>
用户输出
259605
系统信息
Exited with return code 0
20
53
-291 14
-319 278 -699 -876
-867 947 653 -677 138 359 -47 -702
-112 341 -445 -435 -312 -450
<2176336 bytes omitted>
用户输出
37703792
系统信息
Exited with return code 0
20
-654
-404 -914
-142 819 -993 -963
42 -707 292 -964 -857 408 -33 -731
-877 -2 515 206 877 952
<2176313 bytes omitted>
用户输出
38042269
系统信息
Exited with return code 0