janardan_sharma's blog

By janardan_sharma, history, 2 years ago, In English

Could anyone please help me Why my code is giving TLE for problem E of Educational Codeforces Round 118.

  • Vote: I like it
  • -2
  • Vote: I do not like it

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

change grid[i][j] != '#' to grid[i][j] == '.' also dont use endl , use "\n" instead Your code Accepted

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

    Thank you so much man, but can you tell me how changing grid[i][j] != '#' to grid[i][j] == '.'. is decreasing the required time.

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Changing that line of code is not decreasing the execution time, what actually is decreasing the time is the use of '\n' instead of endl.

      endl is very slow and is not suggested to be used in CP, unless you are doing an interactive problem.

      Read more here