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

Автор The_Limit_Does_Not_Exist, 4 года назад, По-английски

Hello all

I was practicing problem on graph theory and I got TLE on this submission.

Later on same code I commented out my 2 debug statements:

cerr << node << "FE" << to << endl;
cerr << node << "BE" << to << endl;

and got AC on this submission.

Why is this so?

So for future submissions should I always remove debug statements and then submit?

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

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

same thing happened with me in this problem

Why is this so ?
Solution
»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

"copy pasted" — This is a very common thing. You are sending output data to the standard error stream through cerr. Outputting data consumes execution time of the program. Codeforces checker will read data output data only from stdout, which is output through cout. But the data that is going to stderr by cerr is still going there, which consumes execution time and hence the code TLEs. So, always remember to comment the cerr statement in your code before submitting so that it doesn't happen.
do not use endl its time consuming too. find why on google

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

    Thanks brother! I'll make sure to remove stderr statements from now.

    I wonder why a simple genuine question gets so many downvotes XD

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

      because this question has been asked several times in blogs and answered too and you asked it once more without google thoroughly about the issue.