mm944's blog

By mm944, history, 6 years ago, In English

Hi guys, I'm new to CodeForces, but I enjoy it a lot, recently I have stumbled upon a problem and was wondering if anyone could help me. I was solving a problem using an algorithm with O(n)[1 <= n <= 10^5], however when I submitted it, I got TLE, it was weird, as I was not using any while loops that could get stuck and wasn't using any libraries, my code was composed of 3 for loops. I checked the test case and the output was quite large, and all I could think of is that printing the output was time-consuming(which is still weird, because I need to output less than 10^5 lines), I use PascalABC/FreePascal, because I enjoy it, but this is quite annoying. What would you recommend to do, switch to another language, or there is another issue and output has nothing to do with it. It happened to several problems, but here's the last one, thank you!

https://mirror.codeforces.com/contest/1062/submission/52135801

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

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I think there's something wrong with your program, since it printed some negative numbers on testcase #3.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Hi, thank you for your comment. You're right my program does output some negative numbers, this is due to the way I compute the answer, rather than writing the answer as a difference I could write it as a product, but still it should say Wrong answer, rather than TLE, anyways thanks for your answe, have an A1 day!

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      It means that the code has outputted a bunch of numbers and then hit the time limit halfway through. You might want to try flushing your output only once instead of flushing after each line. That will help improve the speed. Of course, if the code is wrong then that needs to be fixed first.