Skip to content

feat: 完成2018fall所有公开问题#13

Merged
Certseeds merged 46 commits intomasterfrom
develop
Sep 27, 2025
Merged

feat: 完成2018fall所有公开问题#13
Certseeds merged 46 commits intomasterfrom
develop

Conversation

@Certseeds
Copy link
Owner

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

均经过oj检验

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
gemini2.5pro, gpt5都无法给出正确结果, 抬一级到 Claude Opus4.1才给出暴力解

Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 27, 2025 09:38
@Certseeds Certseeds added the enhancement New feature or request label Sep 27, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements solutions for all public problems from the 2018 fall semester's lab assignments. It adds complete implementations for Labs 7, 8, and 9, covering various data structures and algorithms including stack/queue problems, graph algorithms, tree operations, and advanced data structure applications.

Key changes:

  • Added comprehensive solutions for Lab 7 (5 problems), Lab 8 (6 problems), and Lab 9 (10 problems)
  • Implemented various algorithms including BFS/DFS, MST, shortest paths, topological sorting, and graph connectivity
  • Provided detailed documentation and analysis for each problem solution

Reviewed Changes

Copilot reviewed 299 out of 397 changed files in this pull request and generated 3 comments.

File Description
2018fall/lab_9/ Complete implementation of 10 graph and tree algorithm problems with comprehensive READMEs
2018fall/lab_8/ Implementation of 6 data structure problems including complex graph algorithms and cactus structures
2018fall/lab_7/ Implementation of 5 problems covering tree operations, bubble sort simulation, and advanced data structure queries

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +66 to +70
private static long solveOne(final TestCase tc) {
final int n = tc.n, m = tc.m;

// build adjacency: store neighbor and edge-id
final ArrayList<int[]>[] adj = new ArrayList[n + 1];
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using raw types with generic collections. Consider using @SuppressWarnings("unchecked") annotation and proper generic type casting instead of raw types.

Suggested change
private static long solveOne(final TestCase tc) {
final int n = tc.n, m = tc.m;
// build adjacency: store neighbor and edge-id
final ArrayList<int[]>[] adj = new ArrayList[n + 1];
@SuppressWarnings("unchecked")
private static long solveOne(final TestCase tc) {
final int n = tc.n, m = tc.m;
final ArrayList<int[]>[] adj = (ArrayList<int[]>[]) new ArrayList[n + 1];

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +58
// If K is large enough to fully sort by repeated bubble passes, you could optimize by
// checking K >= n and sorting, but here we keep it purely naive as requested.
for (int pass = 0; pass < K; pass++) {
boolean swapped = false;
for (int i = 0; i + 1 < n; i++) {
if (a[i] > a[i + 1]) {
int tmp = a[i];
a[i] = a[i + 1];
a[i + 1] = tmp;
swapped = true;
}
}
if (!swapped) {
break; // already sorted
}
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naive bubble sort implementation has O(n²K) complexity which may cause TLE for large inputs. The C++ version uses a more efficient O(n log n) algorithm that should be considered for the Java implementation as well.

Suggested change
// If K is large enough to fully sort by repeated bubble passes, you could optimize by
// checking K >= n and sorting, but here we keep it purely naive as requested.
for (int pass = 0; pass < K; pass++) {
boolean swapped = false;
for (int i = 0; i + 1 < n; i++) {
if (a[i] > a[i + 1]) {
int tmp = a[i];
a[i] = a[i + 1];
a[i + 1] = tmp;
swapped = true;
}
}
if (!swapped) {
break; // already sorted
}
// If K is large enough to fully sort by repeated bubble passes, optimize by sorting.
if (K >= n) {
Arrays.sort(a);
} else {
for (int pass = 0; pass < K; pass++) {
boolean swapped = false;
for (int i = 0; i + 1 < n; i++) {
if (a[i] > a[i + 1]) {
int tmp = a[i];
a[i] = a[i + 1];
a[i + 1] = tmp;
swapped = true;
}
}
if (!swapped) {
break; // already sorted
}
}

Copilot uses AI. Check for mistakes.

while (!q.isEmpty()) {
final int u = q.poll();

Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The pruning condition dist[u] * 2 >= ans lacks a comment explaining the mathematical reasoning. Consider adding a comment to clarify why this bound is valid for the multi-source BFS algorithm.

Suggested change
// Prune the BFS: If the shortest path found so far (ans) is less than twice the current distance from a source (dist[u]),
// then any new path discovered from this node cannot improve the answer. This is because the shortest cycle between
// two different sources must be at least dist[u] + dist[v] + 1, and both dist[u] and dist[v] are at least dist[u].

Copilot uses AI. Check for mistakes.
@Certseeds Certseeds merged commit 7837d90 into master Sep 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Development

Successfully merging this pull request may close these issues.

3 participants