You are getting SIGSEGV
A SIGSEGV is an error(signal) caused by an invalid memory reference or a segmentation fault. You are probably trying to access an array element out of bounds or trying to use too much memory. Some of the other causes of a segmentation fault are : Using uninitialized pointers, dereference of NULL pointers, accessing memory that the program doesn’t own.
Firstly @acodebreaker2 is correct that you are not returning 0 which should throw NZEC SO you must add return 0 to your code,
But i see your code is throwing SIGSEGV (you may read about SIGSEGV here) which may be due to an array element out of bounds or trying to use too much memory (seems to be happening in this case), btw I don’t know dp but what i can observe is you are initializing a 2-D array,
But when i see the constraints Max N can be 21 and
and so Segmentation Fault is occurring, because as far i know we can initialize an array of 10^6 elements…!
You may check this stackoverflow link for SIGSEGV on storing large number in a 2D array!!
Yes it’s correct .But my code is not working for at least sample test cases which are given in problem page.So can you please help me in according to logic which is implemented using Editorial. Thanks