It is impossible to think of the solution to a problem on the
spot, especially if it is a complex problem. The only way is if you
have walked yourself mentally through the whole thing.
For example if you make this decision, what are the possible
outcomes of it and if it is A, what would you do, B what is your
next decision etc etc. Only then can you so call think and decide
on the spot. Only if you walk through the whole thing.