Yasuho_Hirose's blog

By Yasuho_Hirose, history, 3 years ago, In English

here is my solution: https://mirror.codeforces.com/contest/1624/submission/144304382 for this problem: https://mirror.codeforces.com/contest/1624/problem/E I think time complexity of this solution is O(n*m) is small enough, but why this still give TLE? Thanks you for read my shi* blog.

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

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

probably because of using memset for every testcase.

memset(t2,0,sizeof(t2));

with 10000 testcases and t2 of the size 1000, this TLEs

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

Oh

I often suffer from this problem also.

The reason of you getting TLE is because you code's runtime is longer than the time limit (i.e. 3 seconds)

What you should do is to code a code with a shorter runtime which is shorter than the time limit.

But then how do you know if the new code have a runtime shorter than the time limit or not?

You can then simply submit your code to the online judge (i.e. codeforces) to the corresponding question.

If your code have a runtime shorter than the time limit, codeforces will return a green, “Accepted" word.

but then if your code have a longer runtime than the time limit, codeforce will return a blue,"Time Limit Exceeded on Test XX" where XX is a number.

Hope this will help.