Skip to content

Commit f83161a

Browse files
committed
modify code
1 parent 271939e commit f83161a

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/class182/Code02_Minimax1.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,21 @@ public static int merge(int l, int r, int t1, int t2, int p, long sum1, long sum
136136
}
137137

138138
// 迭代版,java会爆栈,C++可以通过
139-
public static void dfs1(int u) {
139+
public static void dp1(int u) {
140140
if (sonCnt[u] == 0) {
141141
root[u] = insert(arr[u], 1, cntv, root[u]);
142142
} else if (sonCnt[u] == 1) {
143-
dfs1(son[u][0]);
143+
dp1(son[u][0]);
144144
root[u] = root[son[u][0]];
145145
} else {
146-
dfs1(son[u][0]);
147-
dfs1(son[u][1]);
146+
dp1(son[u][0]);
147+
dp1(son[u][1]);
148148
root[u] = merge(1, cntv, root[son[u][0]], root[son[u][1]], arr[u], 0, 0);
149149
}
150150
}
151151

152-
// dfs1改成迭代版
153-
public static void dfs2() {
152+
// dp1改成迭代版
153+
public static void dp2() {
154154
int[][] stack = new int[n + 1][2];
155155
int siz = 0;
156156
stack[++siz][0] = 1;
@@ -238,8 +238,8 @@ public static void main(String[] args) throws Exception {
238238
arr[i] = in.nextInt();
239239
}
240240
prepare();
241-
// dfs1(1);
242-
dfs2();
241+
// dp1(1);
242+
dp2();
243243
getd(1, cntv, root[1]);
244244
long ans = 0;
245245
for (int i = 1; i <= cntv; i++) {

src/class182/Code02_Minimax2.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333
//int root[MAXN];
3434
//int ls[MAXT];
3535
//int rs[MAXT];
36-
//int cntt;
37-
//
3836
//long long sum[MAXT];
3937
//long long mulLazy[MAXT];
38+
//int cntt;
4039
//
4140
//long long D[MAXN];
4241
//
@@ -133,15 +132,15 @@
133132
// return t1;
134133
//}
135134
//
136-
//void dfs(int u) {
135+
//void dp(int u) {
137136
// if (sonCnt[u] == 0) {
138137
// root[u] = insert(arr[u], 1, cntv, root[u]);
139138
// } else if (sonCnt[u] == 1) {
140-
// dfs(son[u][0]);
139+
// dp(son[u][0]);
141140
// root[u] = root[son[u][0]];
142141
// } else {
143-
// dfs(son[u][0]);
144-
// dfs(son[u][1]);
142+
// dp(son[u][0]);
143+
// dp(son[u][1]);
145144
// root[u] = merge(1, cntv, root[son[u][0]], root[son[u][1]], arr[u], 0, 0);
146145
// }
147146
//}
@@ -200,7 +199,7 @@
200199
// cin >> arr[i];
201200
// }
202201
// prepare();
203-
// dfs(1);
202+
// dp(1);
204203
// getd(1, cntv, root[1]);
205204
// long long ans = 0;
206205
// for (int i = 1; i <= cntv; i++) {

0 commit comments

Comments
 (0)