Editorial for GlobeX Cup '18 S4 - Reversed Dijkstra's
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For the first subtask, note that
Time Complexity:
For the second subtask, it suffices to simply check every possible path in the graph from
Note that due to the number of edges (
Time Complexity:
For the final subtask, note that we can use a visited array to skip redundant paths. Two paths from
We can prove this by looking at any two paths from
- Both paths have the same length, since it's not allowed to backtrack and they visited the same [amount of] vertices.
- The vertices that both paths can visit from
onward are the same, since they have already visited the same vertices and the paths cannot backtrack.
These observations show that both paths are functionally the same and thus it would be redundant to search onward from any more than one of the paths.
Time Complexity:
Author's note: Note that this problem is extremely similar to CCO '15 P2 - Artskjid, hence the [very original] problem name.
Comments
This comment is hidden due to too much negative feedback. Show it anyway.