Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Yuchang_Zhu's blog

By Yuchang_Zhu, history, 15 months ago, In English

I'm so mad that C is wrong because I got the wrong data type!

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

| Write comment?
»
15 months ago, # |
Rev. 2   Vote: I like it +6 Vote: I do not like it

Don't be mad, take it as experience for later contests.

(Yesterday I used the wrong datatype for problem B, submitted and locked the problem immediately without optimizing the code. I was so careless and got TLE on test 9. After finished the contest, I just changed a few lines of code and it was Accepted. What a pity!)

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

Join the #define int long long cult! Everyone hates us, and they got a point, but this kind of mistake won't ever happen to you again

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

A good way to avoid these mistakes is to do a mental estimation of the upper bound of the absolute value before assigning datatypes. For example, if there's an array with $$$\le 2 \cdot 10^5$$$ elements between $$$-10^9$$$ and $$$10^9$$$, any subset sum of this array will be between $$$\pm 2 \cdot 10^{14}$$$, which clearly needs a 64-bit integer type. I try to be as specific about the bounds as possible, and it helps me verify my implementation as well, so I'd recommend others to do this too.

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

Me too!