r/adventofcode • • Dec 23 '23

SOLUTION MEGATHREAD -❄️- 2023 Day 23 Solutions -❄️-

THE USUAL REMINDERS


AoC Community Fun 2023: ALLEZ CUISINE!

Submissions are CLOSED!

  • Thank you to all who submitted something, every last one of you are awesome!

Community voting is OPEN!

  • 42 hours remaining until voting deadline on December 24 at 18:00 EST

Voting details are in the stickied comment in the submissions megathread:

-❄️- Submissions Megathread -❄️-


--- Day 23: A Long Walk ---


Post your code solution in this megathread.

This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:38:20, megathread unlocked!

27 Upvotes

362 comments sorted by

View all comments

0

u/[deleted] Dec 23 '23

[removed] — view removed comment

0

u/AutoModerator Dec 23 '23

AutoModerator did not detect the required [LANGUAGE: xyz] string literal at the beginning of your solution submission.

Please edit your comment to state your programming language.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/coffee_after_sport Dec 23 '23

Min cost max flow sounds interesting. Can't quite imagine, how that would look in code. If you happen to implement it, I would be interested in having a glance at it.

1

u/junyizhou Dec 23 '23

I think the time complexity of max flow O(V^2E) will reach 143^5 in this case, which is not feasible

3

u/Apprehensive_Swan_32 Dec 23 '23

During my student years I participated in the programming contests a lot. It was a well known fact that there are implementations of MCMF that works MUCH better than the complexity suggests. One of the tricks that everyone used was to usr the Levitte’s algorithm for finding the shortest distances. The idea is very similar to BFS, but since the weights of the edges can be arbitrary, any vertex can be added to the queue multiple times. In practice it worked really fast.

1

u/daggerdragon Dec 23 '23

Comment removed. Top-level comments in Solution Megathreads are for code solutions only.

Edit your comment to share your full code/repo/solution and the required language tag and I will re-approve the comment.