With reference to the problem, http://mirror.codeforces.com/contest/721/problem/C
http://mirror.codeforces.com/contest/721/submission/21096367 -> This submission with memset giving value of 1e9+7 to 2D array gives WA on test10
whereas the same code with memset removed and the 2D array given value manually of 1e9+7 ->http://mirror.codeforces.com/contest/721/submission/21096181 gives AC.
I am completely not able to understand why?? Does anyone have any idea??
memset works only when we have to initialise the array with 0 or -1 for rest it doesn't work
Thank you. Did'nt know about it.
You don't know how memset works. It works byte by byte not word (4 bytes) by word.
http://www.cplusplus.com/reference/cstring/memset/
memset Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).
Memset works by writing values byte by byte based on the given value. Check out the documentation here!
By the way, if you want to set an array to large values, use memset with 63, this will set all values to 1,061,109,567