First of all apologies if this is something that has been asked before, my searching ability appears to have failed me then.
While using printf with formatting for zero padding on CF (including custom invocation), I encountered this strange behavior:
WA — 109283810
AC — 109284812
The only difference between these two submissions in the language chosen (32bit vs 64bit C++17). Somehow in the 32-bit version, the second argument is always processed as zero.
In the 32-bit C++17 version, splitting the printf into 2 printfs also causes it to get AC — 109284259
Does CF use a different compiler / environment for 64 bit that could explain this difference in behavior?
Is there some undefined behavior in my code that is the source of this inconsistency?
%02d is for a signed integer (int). Since you have done #define int long long, your arguments are actually long longs. So, this is undefined behavior. You need to pass int arguments, or use the %lld format specifier for long long.
Be sure to enable compiler warnings with -Wall -Wextra, which can warn of such mistakes.
You can read more about useful compilation flags by checking out this blog. https://mirror.codeforces.com/blog/entry/79024
Thanks for shilling my blog.