help in codeforces problem 701E - Generate a string

prob : Problem - 710E - Codeforces

Can someone please elaborate the editorialist approach. Thanks in advance.

We replace the relationship between the numbers with the directional edge of value. Then we have to solve the shortest path problem of a directed graph. Further observation can be found that the circle of this graph is not necessary. then the graph become a directed acyclic graph, so we can use on dp to solve this problem。

1 Like

@vivek_1998299 @vijju123 if possible can you please look into it.

friend if you don’t mind can you please explain it more. I didn’t get it.