In http://codility.com/, exist a problem that say:
There are N squares in your neighborhood and M direct roads connecting them. The squares are numbered from 0 to N − 1. You are living in square 0 and can reach it in 0 seconds. The stores are located in the squares, one in each of them. You are given a map of the neighborhood in the form of four zero-indexed arrays A, B, C and D. Each of the arrays A, B, C contains M integers, while D contains N integers. For each I (0 ≤ I < M), the walking distance between squares A[I] and B[I] is C[I] seconds (in either direction)
There can be multiple roads connecting the same pair of squares, or a road with both ends entering the same square.
It is possible that some roads go through tunnels or over bridges (that is, the graph of squares and roads doesn't have to be planar).
It is not guaranteed that you are able to reach all the squares. For each J (0 ≤ J < N), the shop at square J will close in D[J] seconds (if D[J] = −1, then the store is already closed); it is possible to buy the food even if you reach the shop at the very last second, when it closes. Write a function:
int solution(int A[], int M, int B[], int M2, int C[], int M3, int D[], int N);
that, given arrays A, B, C and D, returns the minimum time (in seconds) needed to reach an open store. If it is impossible, it should return −1.
My main problem is identify the problem. I don't have a heavy background in math. I do the test, it work as the sample data provide in the question, but after submit it, the website say is wrong for this data data = [[6, 6, 3, 8, 8, 6, 7, 5, 1, 4, 3, 2, 7, 7], [3, 7, 5, 8, 0, 6, 3, 4, 1, 7, 1, 5, 3, 2], [8, 1, 9, 12, 11, 1, 8, 12, 3, 6, 12, 7, 4, 2], [-1, 1000000000, 1000000000, 999999999, 999999999, 999999999, 1000000000, 1000000000, 1000000000]]
I return -1, but it say I need to return 11. If I start at 0 (home) and try to locate the closer store I get stuck because 0 connect to 8 and 8 lead nowhere. I draw the graph and 0-8 is disconnected from the rest. I suspect is related to http://en.wikipedia.org/wiki/Bridge_(graph_theory) and here is where my knowledge stop.
Is this the proper identification of the problem?
P.D: I'm more interested in understand the problem that have the python code.