ARRGAME2 WA - Reviewed well, but can't find the bug

I’d be grateful for help.

This is a nice practice problem from long contest OCT13 (involving finding pairs b/w 2 arrays s.t. x^y>y^x)
http://www.codechef.com/problems/ARRGAME2http://www.codechef.com/OCT13/problems/ARRGAME2

I’ve tried to implement following the editorial ( http://discuss.codechef.com/questions/26264/arrgame2-editorial ).

Here’s my commented submission: http://www.codechef.com/viewsolution/5262350

I reviewed the code and tested with different inputs (as in problem page comments and my own test cases), but output was fine.
I also tested the sorting and rank functions separately, and couldn’t find any problem there.

Please help me resolve this code.

no of valid pairs can be greater than 10^9. so “vp” must be of type long long or double.
and a small suggestion try to use c++ instead of c in competitive programming. c++ provides
some useful data structures in the form of stl containers and various predefined functions
for sorting , binary search etc.

1 Like

Thanks a lot.
I kept thinking of some problem in algo logic; never bothered to think about the range; thought it was num-of-pairs<=10^5 (though still would’ve needed long :P).
This one can go upto n^2 (10^10), I now see.