I was solving LABYR1 spoj problem [LINK](http://www.spoj.com/problems/LABYR1/) and the problem reduced to finding diameter of tree. But when I submitted it is constantly giving WA. Any help will be appreciated. [LINK OF MY CODE].(http://ideone.com/F8oVbe)