CSES Flight Discount problem: shortest path with one halved-fare edge solved in C++
A DEV Community post walks through a solution to the CSES competitive programming task "Flight Discount". The problem asks for the minimum cost of travelling from city 1 to city n in a directed graph where one flight can be used at half its price. The author's C++ approach runs Dijkstra's algorithm over states that track whether the discount has already been used. Each node keeps two distance values, one for each state, and a priority queue drives the search. The final answer is the smaller of the two distances stored for the destination node.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in