TAJ from July LoC TLE

Can anyone tell me why my code is giving TLE. Here is the link to my solution CodeChef: Practical coding for everyone
Complexity O(Max(E+V,Q)).

Use printf instead of cout for printing the answer and you should be fine!

Got it! Thanks mate!