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

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

The current C11 compiler is GCC 5.1.0, which is very old compared to the latest GCC version : 13.2.1

This doesn't only prevent use of more modern C standards like C17/C2X

But the assembly it outputs is also significantly slower than the newer C++ compiler.

Here is my code for a recent problem 1698G2.

Submitted in GCC C11 5.1.0

Submitted in G++ C20 13.2-64

In pretest, C11 runs at ~1000ms, while C++20 runs at 171ms. That's almost 6x slower, just because the compiler is in outdated.

The former submission get hacked by the following generator (TLE, 3sec)

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t=1,n=2e5,k=n/3;
    cout << t << "\n";
    cout << n << " " << 1 << " " << n << "\n";
    for(int i=0;i<k;i++)cout << 'a';
    for(int i=2*k;i<n;i++)cout << char('a'+rand()%26);
    for(int i=0;i<k;i++)cout << 'a';
    cout<<'\n';
}

While the latter is fine at ~1500ms

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

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

GNU C11 is a 32 bit compiler.
C++20 (GCC 13-64) is a 64 bit compiler.

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

    That is true and I am sure it affects the performance, however the C++17 (GCC7) which is 32 bit is also faster than GNU C11.

    Mike should both put a 64 bit version and a newer version of GCC.