Please read the new rule regarding the restriction on the use of AI tools. ×

issahaddar5's blog

By issahaddar5, history, 9 years ago, In English

I was trying to solve this problem. I solved it using bfs. However, I would like to know how can I generate the whole graph beforehand — before processing it in dfs or any other algorithm- ? Another problem that I would like to employ this technique on is problem A in this contest

  • Vote: I like it
  • 0
  • Vote: I do not like it

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

You can't generate full graph because it's infinite :)

You can press first button as many times as you want and get as big number as you want. BFS looks only for verticles which are at distance not more than some value and there are finite number of vertciles. When BFS from start verticle reaches end verticle it says: "There is path of some length, there are no shorter pathes, so there is no reason to look to other verticles"