Codeforces и Polygon могут быть недоступны в период с 23 мая, 7:00 (МСК) по 23 мая, 11:00 (МСК) в связи с проведением технических работ. ×

Блог пользователя iamstg

Автор iamstg, история, 8 лет назад, По-английски

With reference to the problem, http://codeforces.com/contest/721/problem/C

http://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://codeforces.com/contest/721/submission/21096181 gives AC.

I am completely not able to understand why?? Does anyone have any idea??

  • Проголосовать: нравится
  • -8
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится -12 Проголосовать: не нравится

memset works only when we have to initialise the array with 0 or -1 for rest it doesn't work

»
8 лет назад, # |
Rev. 2   Проголосовать: нравится +5 Проголосовать: не нравится

You don't know how memset works. It works byte by byte not word (4 bytes) by word.

»
8 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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).

»
8 лет назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

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‬