Skip to content

Commit cbe3da7

Browse files
committed
modify code
1 parent 674b054 commit cbe3da7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/class165/Code02_UndoUnionFind1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ public static void dfs(int u, int fa) {
7979
boolean added = false;
8080
boolean unioned = false;
8181
if (fx == fy) {
82-
if (edgeCnt[fx] < siz[fx]) {
82+
if (edgeCnt[fx] == siz[fx] - 1) {
8383
ball++;
8484
added = true;
8585
}
8686
edgeCnt[fx]++;
8787
} else {
88-
if (edgeCnt[fx] < siz[fx] || edgeCnt[fy] < siz[fy]) {
88+
if (edgeCnt[fx] == siz[fx] - 1 || edgeCnt[fy] == siz[fy] - 1) {
8989
ball++;
9090
added = true;
9191
}

src/class165/Code02_UndoUnionFind2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@
7575
// bool added = false;
7676
// bool unioned = false;
7777
// if (fx == fy) {
78-
// if (edgeCnt[fx] < siz[fx]) {
78+
// if (edgeCnt[fx] == siz[fx] - 1) {
7979
// ball++;
8080
// added = true;
8181
// }
8282
// edgeCnt[fx]++;
8383
// } else {
84-
// if (edgeCnt[fx] < siz[fx] || edgeCnt[fy] < siz[fy]) {
84+
// if (edgeCnt[fx] == siz[fx] - 1 || edgeCnt[fy] == siz[fy] - 1) {
8585
// ball++;
8686
// added = true;
8787
// }

0 commit comments

Comments
 (0)