code for DRHTS works correctly for 5000 vertices, but gives WA at codechef

i worked a lot on this code of mine(prob statement DRGHTS Problem - CodeChef) bt couldnt find the bug…
then i wrote a generator file and got a valid test case of 50, 100 and then 5000 vertices.
then i compared my codes o/p with that of one which was ACCEPTED at codechef…
both codes give exactly same op, wht should i do??
i am new to coding, and i guess it could be some silly mistake like nt taking long long to prevent overflow…please help guys i have spent a lot of time on this.i request jst spare a minute find if thres a syntax eror of that sort.
heres the comparision :
50 vertices :
ACC : Vl6ch6 - Online C++0x Compiler & Debugging Tool - Ideone.com
mine : Ku1lll - Online C++0x Compiler & Debugging Tool - Ideone.com

100 vertices :
ACC : jMxdOQ - Online C++0x Compiler & Debugging Tool - Ideone.com
mine : IYPIzo - Online C++0x Compiler & Debugging Tool - Ideone.com

5000 vertices :
ACC : DRheT5 - Online C++0x Compiler & Debugging Tool - Ideone.com
mine : d6YmAP - Online C++0x Compiler & Debugging Tool - Ideone.com