I was solving problem F of ABC just now. And I got passed with long long, but when I change the type into __int128_t, it got wrong answer in most of the cases. Why is that?
Upd: It is said that __int128_t can not be the index of array. It may cause wrong answer. So it is always not a good idea to use things like #define int __int128_t.
Upd2: I just tested some other things on AtCoder about __int128_t, it seems template<typename> may work incorrectly with __int128_t. That's from my function read(). I searched for many times in Google but have not found why.








Auto comment: topic has been updated by 0x0002 (previous revision, new revision, compare).
Auto comment: topic has been updated by 0x0002 (previous revision, new revision, compare).
Auto comment: topic has been updated by 0x0002 (previous revision, new revision, compare).
Auto comment: topic has been updated by 0x0002 (previous revision, new revision, compare).
Auto comment: topic has been updated by 0x0002 (previous revision, new revision, compare).
I had some problem in problem B as well. If I use
islowerandisupperfunction to calculate lowercase and uppercase character count I get Wrong answer but passed without inbuilt function. Is it a problem with compiler?My submission using
islowerand the same version of compiler got AC.Google the cppreference for islower/isupper and check the output of islower('a')/isupper('A'). You'll be surprised how stupid it is.
Ugh this is some crazy shit. Thanks a lot!
islowerandisupperare old C-style functions which returnintwith 0 for false and non-zero for true. So you had to write your code as any C programmer:!!islower(ch)In fact I had the same problem due to this function and got a penalty. The fact is that this function does not return a bool result as we expected. Function
islower()returns a non-zero value when it is a lowercase letter. You can check here for details.You can try the below code in custom test to see:
Thanks a lot. On my machine it prints
0, 1, 1, 1only. Probably different compilers have different implementations?That is true because the standard only requires to return a non-zero value, but what it really returns may be different in different compilers.