Please help to calculate time complexity

Revision en1, by MasterInDreams, 2022-11-22 11:58:27

Code

I think it is $$$O(q / K * (n + m + q + K^2 + K * (log(n) + K / 64)))$$$.

Unfortunately for $$$1 ≤ n ≤ 50000; 1 ≤ m ≤ 150000; 1 ≤ q ≤ 250000, K = 456$$$ it works more than 10 seconds.

$$$K / 64$$$ is for queries when I calculate (on & have[id[u[i]]]).count() and $$$K ^ 2$$$ is clearing $$$have$$$.

I am solving 398D - Instant Messanger and don't understand why my solution is so slow, I tried to change values of $$$K$$$ and the best results I got is 4211 ms with $$$K = 2000$$$.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English MasterInDreams 2022-11-22 17:48:26 47 Tiny change: '= 2000$.\n' -> '= 2000$.\n\n**UPD** : I made $K = 6000$ and got Accepted.'
en1 English MasterInDreams 2022-11-22 11:58:27 550 Initial revision (published)