runtime error in RRFRNDS .

Can anyone tell me why my solution is giving Runtime Error.
I am unable to figure it out.

Here’s my solution - CodeChef: Practical coding for everyone

Firstly i thought memory allocation could be the problem but then i got through this AC solution CodeChef: Practical coding for everyone by some user which has similar kind of memory allocation and got accepted. Plz help me to figure out the problem.

You should declare size of arrays greater than 2000.

1 Like

i modified my code and now it is responding well to the cases but getting a TLE. here’s my solution - CodeChef: Practical coding for everyone

because maximum size of n is 2000. But string also takes one extra character as null character at the end of string. Hence size greater than 2000 is needed…

1 Like

thanks a lot … can you also figure out why the code is getting WA.

your solution is giving wrong answer for the following test case-
4
0100
1000
0001
0010
your solution gives 2 but correct answer is 0. Because 1 is friend with 2 , 3 with 4. So, no mutual friends.

1 Like

And i also got the fact that i declared the array of size char[2000][2000] but it should be char[2000][2002] because it is a string . else in case of int i think it would work with 2000 only.