B binsearch and dijkstra
p500 is hard