help in codeforces problem 701E - Generate a string

prob : http://codeforces.com/problemset/problem/710/E?mobile=false

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

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

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

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