Skip to content

Conversation

@Seol-JY
Copy link
Contributor

@Seol-JY Seol-JY commented Apr 1, 2025

🧷 문제 링크

https://www.acmicpc.net/problem/2098

🧭 풀이 시간

60분

👀 체감 난이도

✏️ 문제 설명

전형적인 TSP 문제, 근데 시간제한이 빡센..

🔍 풀이 방법

TSP는 결국 사이클이 형성되었을때의 최단거리 이므로, 시작 지점이 중요하지 않음.
DP 배열을 현재까지의 방문을 표현하는 비트와 마지막으로 방문한 지점 값으로 두고, 메모이제이션 수행
재귀 호출로 필요한 값 차례대로 구하고 종료

⏳ 회고

너무 어렵다... 뭔가 아이디어는 떠올랐는데 구현을 도저히 못하겠어서 참고함.

@Seol-JY Seol-JY added the hint 💡 반례를 참고했거나 힌트를 얻고 풀었을 때 label Apr 1, 2025
@Seol-JY Seol-JY requested a review from Copilot April 1, 2025 17:30
@ShinHeeEul ShinHeeEul merged commit e2de9b3 into main Apr 1, 2025
1 check passed
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 pull request implements a solution for the BOJ TSP problem using a recursive DFS with memoization.

  • Implements TSP solution using recursion with memoization
  • Uses bit masking to represent visited cities
  • Reads the input through BufferedReader and processes the TSP via a dp table

Copy link

Copilot AI Apr 1, 2025

Choose a reason for hiding this comment

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

The dp array size calculation may lead to an off-by-one error since the visited states range from 0 to (1<<N) - 1. Consider using 'dp = new int[N][1<<N]' to ensure all states are safely covered.

Suggested change
dp = new int[N][(1<<N) - 1];
dp = new int[N][1<<N];

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

이게 뭐셔..ㄷㄷㄷ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hint 💡 반례를 참고했거나 힌트를 얻고 풀었을 때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants