Блог пользователя NothingOccurred

Автор NothingOccurred, 6 месяцев назад, По-английски

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

  • Проголосовать: нравится
  • +51
  • Проголосовать: не нравится

»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    6 месяцев назад, # ^ |
      Проголосовать: нравится +6 Проголосовать: не нравится

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

  • »
    »
    6 месяцев назад, # ^ |
    Rev. 3   Проголосовать: нравится +21 Проголосовать: не нравится

    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.