In problem 1163F, I used a cumbersome code implementation to solve this problem.
And I met some mysterious problem about efficiency of the code,here is the problem.
I got TLE when I submit this code.
At first I think is there anywhere I forgot to use long long(because it may cause some while conditions error). So I use #define int long long
at the front of the code.
Then it got accepted? After that I checked every variables and arrays is sure to be in int.
Submission 2(define int long long,c++20,64bits)
So I remove #define int long long and resubmitted it in language c++17 (32bits) and got accepted.
Why #define int long long
can cause a 2.5x efficiency difference? I'm very confused about it.
There may be some English grammar errors but they may not affect the reading. Please point them out.qwq
Auto comment: topic has been updated by NothingOccurred (previous revision, new revision, compare).
you used a 64-bit compiler, so it made sense that long long runs faster than int
But I use a 64 bit compiler and always int code runs faster than long long
Yes, I know that individual int operations may be slower in 64bits than long long, but the difference is very small, generally not more than 10%.For big arrays usually int is still faster.
But why is there such a huge difference?
And I think 64bits will only make long long faster,not make int slower.