ps06756's blog

By ps06756, history, 8 years ago, In English

Hello, I have been trying to solve the following problem which was a part of Topcoder SRM 696 Div1 Easy.

I am unable to find a editorial for the problem and I am not able to solve it. Can someone please tell me how to approach this problem ?

Full text and comments »

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

By ps06756, history, 8 years ago, In English

Hello all, I am trying to solve the problem Sausage Maximization. I am solving it using the approach mentioned in the editorial for the question.
I am getting Wrong answer on Test 33 on the following submission. Submission
I have tried a lot of test cases, but I am unable to find any error in the implementation. It would be really helpful, if someone could point out some error in the implementation,

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By ps06756, history, 8 years ago, In English

Hello all, I have tried unsuccessfully to solve the problem Bear and the Polynomials

I am unable to understand the editorial posted for the problem, can some one please post their approach to solve the problem, or explain the approach discussed in the editorial clearly.

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By ps06756, history, 8 years ago, In English

Hello All,

I have been trying to solve the problem HomeTask, but I am unable to devise my own solution, nor I am able to understand the approach discussed in the problem.
Here is the problem Hometask
It would be really helpful, if somebody could tell me how to solve this question or maybe elaborate on the approach given in the editorial.
Thank you

Full text and comments »

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

By ps06756, history, 8 years ago, In English

Hello all, I am trying to understand the algorithm mentioned in the editorial for the following problem
Zuma Here is its editorial editorial.

In the case, when the ith color matches with the kth color in the range [i...j], shouldn't we be doing

D[i][j] = D[i+1][k-1] + D[k+1][j] + 1, instead of
D[i][j] = D[i+1][k-1] + D[k+1][j]
?

This is because, we have to destroy the matching characters in ith position with kth position also, which will take 1 step extra.

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By ps06756, history, 9 years ago, In English

Hello, in this article I would be telling an alternative solution to the problem 580B - Kefa and Company

Most of the solutions , which I have seen use Binary search to solve the problem after sorting of course, so the overall complexity of the solution is O(nlogn) + O(nlogn). I am discussing approach with the complexity of O(nlogn) + O(n). Here , the first O(nlogn) is due to sorting. So, after sorting there is a great improvement in the algorithm complexity. My approach is similar to Z-algorithm for string matching.

Just like Z-algorithm, we maintain a Z[i] array which will contain two things (ie a pair<int,int>), first the maximum index till which we can invite friends starting at ith position and second the total cost of doing so.

Now, while iterating over the entire array, we check whether the current index is less than the Z[i-1].first, if it is so then we immediately know that Z[i].first is at least Z[i-1].first and we iterate from there and update the Z array.

For any clarification, please see my following submission 13210753

Full text and comments »

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