Runtime Error(SIGSEGV) in TRIPS

Hello! I’m getting Runtime Error(SIGSEGV) in trips. Would anybody help me find out the error!
problem link: http://www.codechef.com/problems/TRIPS
solution link: http://www.codechef.com/viewsolution/5195842
I’ve also tried the int long to long long , long unsigned…but getting the same error.
thanks…

The size of your array is n so the highest index you can access is n-1 but you are accessing index n as well so declare a bigger array.

2 Likes

I’ve increased the array size and optimize the code …But…
still getting W.A.
solution link: http://www.codechef.com/viewsolution/5208274
cud u suggest me the test cases where the code is failing…thanks!!

Your corrected code : http://ideone.com/a3hF8j

seems like you are using a matrix to represent the graph which won’t work because n <= 10^5. Your approach seems wrong too. Have you read the Editorial ? If not read it and any data structure or algorithm you don’t understand learn it from here : http://discuss.codechef.com/questions/48877/data-structures-and-algorithms

@topcoder_7 Atleast explain where he’s going wrong or give some hint. Directly giving him the solution is not going to help him.

1 Like

If he compares the solution he’ll know. I’ve include the part which he has to remove from his code in comment region(/***/)