check constraints, N can go upto 10^5 but you just took an array of 10^4+1. And from your code what i can see is, you are checking whether frog-A can send message to frog-B or not for each query. I haven’t tried this but I think you will get TLE because queries can also go upto 10^5.
Not Actually Mistake but:
- In sort function i don’t think you need to do
long longwill be always enough, though prefer
int64_tif you are using
My Solution : https://www.codechef.com/viewsolution/30053370