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

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

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

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

friend if you donâ€™t mind can you please explain it more. I didnâ€™t get it.