Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

2019mcb1220's blog

By 2019mcb1220, history, 5 weeks ago, In English,

Recently i was giving a competition, specifically Codeforces round #647 div 2 and in the problem B (1362B - Johnny and His Hobbies), I thought the brute force approach would give TLE, as the complexity was O((n^2)logn) and combined with number of test cases it would give operations of nearly 10^10, which wont fit 1 second time. But at last i submitted the bruteforce and it passes the pretests. So, i just want to know if the number of test cases has any effect on the overall time complexity of the program. Thank you.

  • Vote: I like it
  • 0
  • Vote: I do not like it

5 weeks ago, # |
  Vote: I like it +6 Vote: I do not like it

Notice: "It is guaranteed that the sum of n over all test cases will not exceed 1024". Therefore we can essentially assume one huge test case, so the brute force only does n^2 * log(n) operations, which is at most 1.05e7.