The_Limit_Does_Not_Exist's blog

By The_Limit_Does_Not_Exist, 4 years ago, In English

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?

| Write comment?
»
4 years ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

same thing happened with me in this problem

Why is this so ?
Solution
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

"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 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.