Comments

Instead of fixing indexes, try to fix the characters occuring at the first position. When you are fixing the indexes your solution is resulting in an O(N^2) time complexity. Since there are only 26 possible characters you can reduce the complexity of your code from O(N^2) to O(26*N)

Valid AP

Consider the sequence A, a1, a2, a3, a4 .... an, B. For the sequence to be a valid arithmetic progression, the difference between consecutive elements should be constant; say d.

a1 — A = d, a2 — a1 =d, a3 — a2 = d .... B — an = d. Adding all these equations we get

a1 — A + a2 — a1 + a3 — a2 ...B — an= (n+1)d.

Simplifying the equation gives (n+1) * (d) = B-A. For an integral solution to exist (B-A) should be divisible by n+1.

C++ Implementation

Make Square

In order to form a square from the given sticks, the length of all the sticks should be made equal. Since it is possible to only reduce the lengths of the sticks, it would be optimum to make all the sticks equal to the smallest stick in length. It can be argued that this would result in the minimum total wastage.

C++ implementation

Minimise Operations:

The circular sequence is a sequence of consecutive characters which begin with any english alphabet. There are only 26 possibilities for the first character. For all the 26 possibilities the cost of converting the string to a circular sequence can be calculated. The final answer would be the minimum cost among all the 26 possibilities.

Time Complexity: O(26 * n)

C++ Implementation

Reminder The contest starts soon. Remember to fill the form to be eligible for prizes!

We have decided to postpone the contest to 10th March,2023 — 08:00PM IST :)

Really, Sorry but it won't be possible to reimburse the travel expenses. However, we would be making bus arrangements to some Indian cities .

Yes, accomodation would be provided to all the finalist teams.

+1

There is a small observation.Say the current number is x. If x%10 is 2, and you perform operations you get a series. 2->4->8->6->2 so after performing 5 operations from any of these numbers you get back to the number itself with a sum of 20.Now suppose x%10 is 1,3,7 or 9. again if you perform one operation you reach 2,6,4,8 respectively.So the numbers become a part of the series.Now the only numbers which cannot be a part of these series are 0,5.So there are three cases.

  1. The array has numbers of the form 0,5 and at least one number from rest of the numbers.In this case the answer is No.
  2. The array has numbers only of form 0,5. In this case for the numbers having x%10=5 do the operation once.Now all elements end with 0 in the array, so no operation can be don further.Now all elements in the array must be equal for an answer to exist.If all elements are equal answer is Yes.Else answer is No.
  3. Now if all elements are of the form 1,2,3,4,6,7,8, or 9.For numbers having 1,3,9 do the operation once.So now all numbers are of form 2,4,6,or 8 in the end.Now as mentioned we can add 20 to any of these numbers without any issue. So we add 20 to all numbers such that the difference between all numbers of 20 is within 20.Now we try to make all elements of this array equal to the maximum element of the array using operations on each of the element. suppose the maximum element of the array is 38, We would try to make all elements of the array equal to 38 46 52 or 54.If is it possible to make all elements equal to any of these elements answer is Yes else answer is No.Note :we are not checking for 58 as if we can make all elements equal to 38 we can also make all elements equal to 54.

For implementation details check this out 166574350

+1

Can anyone explain the dp method for problem D? Thanks in advance

On dario2994 → About div1E (round #810), 4 years ago
+1

Completely agree, the idea of div2 B was really amazing.

Looking forward to an amazing set of problems!