Flight routes graph algorithms solution added #141
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Problem Information
Problem Name: Flight Routes
Category: graph algorithms
CSES Link: https://cses.fi/problemset/task/1196/
Difficulty: [Medium]
📝 Description
This PR adds an optimized solution for the CSES Flight Routes problem.
The task is to compute the k shortest flight routes from city 1 Syrjälä to city n Metsälä in a directed weighted graph.
A route may visit the same city multiple times, and if multiple paths have the same total cost, they must each be considered separately.
The problem is a variation of Dijkstra’s algorithm, but we must track up to k distinct shortest paths per node.
🧩 Solution Approach
Key Optimizations:
4)nSince k ≤ 10, this approach remains efficient even for n = 1e5 and m = 2e5.
✅ Checklist
Please ensure your PR meets these requirements:
Code Quality
Testing
Documentation
Style Guide
#include <bits/stdc++.h>)🏷️ Type of Change
🧪 Testing Details
Describe how you tested your solution:
Test Cases Used:
📸 Screenshots (if applicable)
📎 Additional Notes
Any additional information, considerations, or context for reviewers:
For Maintainers: