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

Автор cloud_007, история, 2 года назад, По-английски

Hi!

I've found this strange thing(maybe not that strange who already knows it). Can anyone explain why this takes less time and memory complexity in C++14 and C++17 compilers than in the C++20 compiler? I've attached the time and memory complexity of this problem below.

Submission Link: C++ 17 C++ 14 C++ 20

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

»
2 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

It's not different time/memory complexity. That'd usually be something like 10000% difference, not 50%. It's different time/memory, which is normal because different compilers produce different code which consumes different resources. If it was always the same, there'd be no point in having those different compilers, no?

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I understand, what I don't is the memory complexity of 120836KB & 187964KB in 17 and 20 respectively.

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

      14/17 are 32 bit, 20 is 64 bit. Any pointers (eg return addresses on stack) are therefore twice as big. On top of that the stack usage for a function is generally higher in x64 due to different alignment / calling conventions.

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

      You can't have memory complexity of 187964KB or 2GB or whatever... Memory complexity can be $$$O(n^2)$$$, $$$O(n)$$$, $$$O(1)$$$, etc.