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

Автор Yasuho_Hirose, история, 2 года назад, По-английски

here is my solution: https://codeforces.com/contest/1624/submission/144304382 for this problem: https://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.

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

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

probably because of using memset for every testcase.

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

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

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

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.