here is my solution: https://codeforces.net/contest/1624/submission/144304382 for this problem: https://codeforces.net/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.
probably because of using memset for every testcase.
with 10000 testcases and t2 of the size 1000, this TLEs
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.