Hello,
With some friends we are very confused because of this. We have these two different codes:
The weird thing is that they are the same code, but the ONLY difference is how we read the input to the global string "path".
On the AC code:
string sAux; // line 69
cin >> sAux;
path = sAux;
On the TLE code:
cin >> path; // line 69
The submission that gives TLE reads directly into the global variable, while the AC code reads into an intermediary local string and then assigns to the global variable.
We have absolutely no idea why or how this makes any difference.
Any ideas? Thanks!
This might be useful
But I think this situation is different, because in both cases "path" is a global variable. The only thing that might change is where "sAux" is stored, but it should not matter because it's only used once (when assigning to "path"), unless the compiler does some weird stuff with "path".
This is interesting. I tried changing a few things, and got the following results (none of these use
sAux
):bool visited[7][7]
passedvector<vector<bool>> visited
did notThen again, the program is very close to the TL, so I'm almost sure it's a small optimization that's causing the issue. For the cases that they both pass, it takes about 10% longer for the
bool[7][7]
. Adding backsAux
only improved the running time by 0.01s.Interesting experimentation. Maybe one would have to look into the assembly to find what
sAux
does.