sleepyessheep's blog

By sleepyessheep, history, 8 months ago, In English

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

Full text and comments »

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