Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

zhiyangfan's blog

By zhiyangfan, history, 5 years ago, In English

`I am trying to solve https://codeforces.me/gym/103470/problem/K.

My solution is similar to the official tutorial(If you don't understand Chineses, it's ok! I write annotation in the code),but I'm troubled with constant factor(maybe not? If my time complexity is not good enough, please point out. qwq ), keeping getting TLE on test 38. :(

I wonder if someone can help me with it, pointing out something wrong with my implementations. qwq

My code.

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

»
5 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Your code has complexity $$$\Omega(\sum \deg^2)$$$ (which could be $$$\Omega(nm)$$$ worst case) for counting $$$C_3$$$ and $$$C_4$$$.

  • »
    »
    5 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Why? qwq

    I think my code is using the proper way of constructing the new graph and can decrease the time complexity to $$$\mathcal{O}(m\sqrt{m})$$$. qwq