I'm so mad that C is wrong because I got the wrong data type!
# | User | Rating |
---|---|---|
1 | Benq | 3783 |
2 | jiangly | 3772 |
3 | tourist | 3706 |
4 | maroonrk | 3609 |
5 | Um_nik | 3591 |
6 | fantasy | 3526 |
7 | ko_osaga | 3500 |
8 | inaFSTream | 3477 |
9 | cnnfls_csy | 3427 |
10 | zh0ukangyang | 3423 |
# | User | Contrib. |
---|---|---|
1 | Um_nik | 183 |
2 | awoo | 181 |
3 | nor | 172 |
4 | -is-this-fft- | 170 |
4 | adamant | 170 |
6 | maroonrk | 165 |
7 | antontrygubO_o | 160 |
8 | SecondThread | 159 |
9 | dario2994 | 152 |
9 | kostka | 152 |
I'm so mad that C is wrong because I got the wrong data type!
Name |
---|
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!)
Thanks for sharing your experience with me.
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
I think that #define long long long cult is better.
Thanks for your opinion,but I think #define int long long is better,because I might not forget.
Thanks for your opinion!
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.
Thanks for your tip!This is a very useful method!
Me too!
hug