Comments
  • Can Someone help with the time complexity of this code: https://mirror.codeforces.com/contest/1593/submission/132395142 for problem D2.
  • I have used dp table for calculating the maximum gcd possible when I consider exactly n/2 numbers( because I have to make atleast half elements equal)
  • dp[i][cnt][last] stores set of GCDs that are possible after considering cnt number of elements upto ith position in the array with index of previous selected element as last.
  • It got submitted with 15ms runtime. According to me, the time complexity of this code is O(n^5 * (log(max(Ai)) + log(n))). I want to know whether I am wrong with the time complexity or test cases are not strong enough !
Reason behind asking this question

Code Can anyone help me with problem D Kill Anton? Here, I have tried to calculate the number of inversions by segment tree. I have solved 1430E-String Reversal using the same segment tree method for calculating the number of inversions, and here is my submission for that. I couldn't figure out what mistake I am making here. Here is my Code for Kill Anton.

0

Thanks a lot! I had to insert sieve() in the main function, not in every test case. Due to that silly mistake, it cost me too much time at debugging. Again thanks a lot.

0

div2-D/div1-B : Can someone explain to me why this code gives TLE as the approach is the same as editorial. Do I need to change the code in implementation?

I think instead of a(i+1)%3 and a(j+1)%3 there should be a(i+2)%3 and a(j+2)%3,correct me if I am wrong. Anyway great explanation!

My bad, I misinterpreted it -_-.

"If the single last digit is odd, then Raze wins, else Breach wins." It is not mentioned that If the single last digit is even then Breach wins. How can you assume that ?

problem E:Can anyone tell me what's wrong with this code as this is giving TLE on test 47. TIA.

can anyone please optimize this code ? thanks in advance. this is my submission