sysjuruo's blog

By sysjuruo, history, 5 weeks ago, In English,

Many participants use std::map in their codes.

If he used type int as the key, he 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

»
5 weeks ago, # |
  Vote: I like it +115 Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

<3

»
5 weeks ago, # |
  Vote: I like it -7 Vote: I do not like it

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

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

define int long long master race.

»
5 weeks ago, # |
  Vote: I like it +4 Vote: I do not like it

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

  • »
    »
    5 weeks 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. :(

»
5 weeks ago, # |
  Vote: I like it -44 Vote: I do not like it

hashtagdefineintlonglong and all your problems are gone

»
4 weeks 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.