sys.'s blog

By sys., 13 months ago, In English

Many participants use std::map in their codes.

If the type of the key is int, it will be hacked by this:

2
2 1 2
10 0 1000000000 999999999 999999998 999999997 999999996 999999995 999999994 999999993 589934621

Because (int) 4294967296LL == 0

 
 
 
 
  • Vote: I like it
  • +175
  • Vote: I do not like it

»
13 months ago, # |
  Vote: I like it +115 Vote: I do not like it

»
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it

<3

»
13 months ago, # |
  Vote: I like it -7 Vote: I do not like it

Yeah, that sucks. Is it going to be rejudged?

»
13 months ago, # |
Rev. 2   Vote: I like it +16 Vote: I do not like it

define int long long master race.

»
13 months ago, # |
  Vote: I like it +4 Vote: I do not like it

Damn You :( How Could You Even Think Of Something Like That? :)

  • »
    »
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    WA on test 25.

    Ohhhhh!!!!I forgot to use long long!!!!!

    Submitted, still WA on test 25. :(

»
13 months ago, # |
  Vote: I like it -44 Vote: I do not like it

hashtagdefineintlonglong and all your problems are gone

»
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it

You can use -Wconversion (mentioned in https://codeforces.com/blog/entry/15547) to avoid this kind of error.

However, in this case, if you forget to let box sum have type long long initially, you'll still get overflow.