Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

bhayanak's blog

By bhayanak, history, 9 years ago, In English

i want an help beecause it is a difficult questions (sorry for mine poor english)

https://www.codechef.com/problems/DIGJUMP

  • Vote: I like it
  • +2
  • Vote: I do not like it

»
9 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

You can make graph with edges between i and i + 1. Also when you visit some verix u with digit x, and you haven't visited any other vertix with the same digit, you can push all of them into the queue, setting the distance to them dst[u] + 1.

Code