Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution9 #375

Open
wants to merge 2 commits into
base: fix
Choose a base branch
from
Open

Solution9 #375

wants to merge 2 commits into from

Conversation

GabageFW
Copy link

@GabageFW GabageFW commented Dec 1, 2024

2023120250-裴基旭
修改的思路:
在本次提交中,我解决了判断是否可以将 n 个人分成两组的问题,并修复了代码中的几个错误。具体修改内容如下:

  1. 图的构建与路径压缩:
    • 在原始代码中,图的邻接关系存在构建问题,因此修改了邻接表的填充逻辑。
    • 改进了按秩合并(unit 方法)和路径压缩(findFa 方法)的逻辑,以优化算法的性能,避免了递归深度过深的问题。
  2. 错误修复:
  • 修复了 StackOverflowErrorAssertionError 问题,确保代码可以在合理的时间内处理较大的输入。
  1. 单元测试:
    • 编写了 JUnit 测试用例,覆盖了 possibleBipartitionunitisconnectfindFa 等方法,确保每个方法的逻辑正确。
    • 通过测试验证了修复后的代码,所有测试用例均通过。
      此修改能够正确判断是否能够将所有人分配到两个组中,并且通过了所有边界条件和特例测试。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant