ComboGirl's blog

By ComboGirl, history, 7 days ago, In English

In the following two submissions 224059045 and 224058953 the only difference is one line where I replaced

memset(dc, n+5, sizeof(dc));

with

for(int i=1;i<=n;i++) dc[i] = n+5;

and it WA on the first but AC with the latter. I'm not sure why this is happening. Any ideas?

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 days ago, # |
  Vote: I like it +13 Vote: I do not like it

Memset basically fills each byte in the range with the specific value given. With your memset you are putting value n+5 in each of the four bytes in dc[i]. That integer dc[i] is not equal to n+5 but something completely different.

»
7 days ago, # |
  Vote: I like it +8 Vote: I do not like it

for values which is not 1 byte, use std::fill instead of std::memset

»
7 days ago, # |
  Vote: I like it -14 Vote: I do not like it

Just skill issues, learn more before doing cp

  • »
    »
    7 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Coming from someone who just posted a blog about help solving Watermelon I'd say your comment applies more to you.