tsort: getting runtime error

http://www.codechef.com/viewsolution/2894486
getting runtime error
but fine on ideone.com
plz help

Declare all your arrays globally. Here is your corrected version. Please refer to FAQ to learn more about errors on code chef.