Huge difference in execution time between G++ 17 and G++ 20 causing TLE.

Revision en2, by SXZZ5, 2024-06-21 11:20:45

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 ( 832ms 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 sets of submissions have no diff at all in the CF "Compare" result.
What explains this ?
What exactly is it thats so bad with how I have written my code. (So that something like this doesn't happen in contest.)

I though G++ 17 solutions should run slower when using 64bits integer throughout the code.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English SXZZ5 2024-06-21 11:26:16 15
en4 English SXZZ5 2024-06-21 11:25:23 2 Tiny change: ': AC ( **832ms only**' -> ': AC ( **842ms only**'
en3 English SXZZ5 2024-06-21 11:23:40 141 (published)
en2 English SXZZ5 2024-06-21 11:20:45 239
en1 English SXZZ5 2024-06-21 11:13:49 904 Initial revision (saved to drafts)