NothingOccurred's blog

By NothingOccurred, 3 months ago, In English

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.

Submission(c++20,64bits).

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.

Submission 3(c++17,32bits)

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

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

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

Auto comment: topic has been updated by NothingOccurred (previous revision, new revision, compare).

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

you used a 64-bit compiler, so it made sense that long long runs faster than int

  • »
    »
    3 months ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    But I use a 64 bit compiler and always int code runs faster than long long

  • »
    »
    3 months ago, # ^ |
    Rev. 3   Vote: I like it +21 Vote: I do not like it

    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.