SXZZ5's blog

By SXZZ5, history, 3 weeks ago, In English

So, while trying this problem 1735D - Meta-set, I encountered huge difference in execution times between G++ 17 and G++ 20.

Submission 1 with G++ 20: 266669242 Verdict: TLE ( 4000ms ).
Submission 2 with G++ 17: 266672467 Verdict: AC ( 842ms only ).

What it took to get the original solution to pass with G++ 20 was to take inputs as char directly instead of reading it as int and then casting to char. That reduced ~200ms of execution time.
Submission 3 with G++ 20: 266672260 Verdict: AC ( 3800ms ).
Submission 4 with G++ 17: 266672385 Verdict: AC ( 718ms only ).

In both scenarios, G++ 17 submssions are approximately 4 times faster ? Both pairs of submissions have no diff at all in the CF "Compare" output.
What explains this ?
How to avoid something like this happening during a contest ?

I used to think G++ 17 solutions should usually run slower when using 64bits integer throughout the code. (because #define int long long).

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