### yeeeet's blog

By yeeeet, history, 4 months ago, ,

Hello, My code is https://ideone.com/uMFdKp When I put in the sample test case 2 2 2 3 5 2 2 It gives a runtime error How can I fix this?

 » 4 months ago, # |   0 vector > v;v[i].push_back(-1);
 » 4 months ago, # | ← Rev. 5 →   0 I tried in your code and found that the issue is not only in v[i].push_back(-1), but also in v[x+dirx[i]][y+diry[i]] in more than one position in the function bfs, here you are visiting places that have not reserved before.For the first one, you haven't had the vectors v[i] yet, so you need either to create another vector and push -1's back to it, then push this vector back to v in each iteration, or to do this: vector > v(N); where N is the size you want for v.For the second one, you need to be sure what you want in your code, so it is up to the idea of your solution.