TLE with memset()

help
c
c-plus-plus
lcpesy

#1

i am not able to figure out why i got TLE with memset in http://www.codechef.com/FEB14/problems/LCPESY .

However , on replacing memset(..., 0 , 256) by for(i=0;i<256;i++) i got AC .

What is the reason ?

UPDATE: I should have used 256*4 for 256 size array . this was my mistake
.


#2

I’m sure, that problem is not with memset() we will see after the contest :wink:


#3

@ac_c0der :

There is also a problem with your syntax. It should be:

memset(array, 0, sizeof(array));

#4

@garakchy : Rather than making dumb comments, go and get a life!


#5

It is correct you have to specify the no of bytes.256 will only fill 64 indexes in int array.So your array is not fully initialized.


#6

it doesnt matter @ac_c0der, memset(array, 0, sizeof(array)); gave TLE anyway. some guys below understand that.