M-I's blog

By M-I, history, 35 hours ago, In English

Today while upsolving this problem from the COMPFEST 18 Final on TLX I found something unexpected

I came up with a $$$O(N \log^2 N)$$$ solution which should have been fast enough for the given constraints My code was well optimize but I kept getting TLE

After spending some time investigating the issue I finally found the problem it was just one compiler flag

Accepted Solution

Spoiler

TLE Solution

Spoiler

My working code had:

#pragma GCC optimize("O3", "unroll-loops")

But my TLE code had:

#pragma GCC optimize("O3", "Ofast", "unroll-loops")

The only difference was Ofast

After removing it my solution passed

I didnt expect adding a optimization flag to make my code slower

Has anyone experienced something similar?

Full text and comments »

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