Блог пользователя mm944

Автор mm944, история, 5 лет назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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!

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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.