• + 2 comments

    There are 2^K different sets for fishes , and total N shops . So total of N by 2^K states , you need the fastest way to reach from 0,i [where i is from [0,2^K-1]] to N,(2^K-1) state. graph is undirected one you can run dijsktra on N,(2^K-1) to all other states.