L3002's blog

By L3002, history, 4 hours ago, In English

So, something interesting happened yesterday. I was solving 1838C - No Prime Differences, I came up with an algorithm having a time complexity of O(n*m), I realized this would work given the constraints of the problem. So, I submitted it and surprisingly. I got Time Limit Exceeded (TLE) for it. At first, I thought, I might have made a mistake where I was unexpectedly running into an infinite loop.

But after trying a bunch of things, NOTHING WORKED...I was quite frustrated.. but what could have I done. So, I cursed myself for being stupid for a few minutes and then moved on with Java (I don't like java, it's too slow at times but somehow it worked, though it took 99% of the time-limit)

Later, I was going through the standing for a previous contest and saw someone in the top of the list using the two different compilers for their solution. He had first used GNU C11 compiler and then used C++23 (GCC 14-64, msys2) and surprisingly he too was getting TLE with GNU C11 compiler.

So, I thought maybe I could try to do this, so I submitted it with C++23 (GCC 14-64, msys2) and VOILA!!, It worked. (All Hail the power of C)

Now, I'm not sure, why it worked, but my best guess is the implementation of I/O functions in the two compilers, might be the reason behind the TLE and the Accepted verdict, but I could be wrong...

So, here I am, asking for help from the good people of codeforces (I don't trust the AI, don't like it either), If anyone could help me with an explanation about this.. Is it really the I/O functions that lead to gap or am I wrong?

Here, are the two submissions for reference.

290776102 290775334

Thanks in advance.

PS: I'm trying to improve so any advice would be appreciated as well.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it