FIRESC - getting TLE

For the question FIRESC, I submitted two answers: this one got AC, while this one gives TLE. The only difference between the two is that in the first one, I have defined two vectors globally, while in the second one, I defined only one of those globally and I am passing the second one as a function argument.

The two vectors:

vector<vector<int> > adj; // vector 1
vector<bool> visited; // vector 2

In the AC solution both the vectors are global while in the TLE solution, only visited is global while adj is passed as an argument.

So my question is that why is passing a vector as an argument giving TLE?

one possible explanation could be that when u pass an array or a vector and then call the fxn recursively it has to be pushed on the stack again and again and then also has to be popped…this happens for all calls…leading to lot of time waste…!!!

//