Dominater069's blog

By Dominater069, history, 8 months ago, In English

We invite you to participate in CodeChef’s Starters 206, this Wednesday, 1st October, rated for 5 stars (i.e. for users with rating < 2200).

Time: 8:00 PM — 10:00 PM IST

Joining us on the problem setting panel are:

Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest. The video editorials of the problems will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here. Hope to see you participating.

Good Luck!

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

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Contest starts in 30 mins.

»
8 months ago, hide # |
Rev. 3  
Vote: I like it +14 Vote: I do not like it

Thanks for the nice problems.

Here Are My Solutions

Problem 1: Gladiator Fights

For the minimum, always pair the current winner with a fresh gladiator of skill 0. This way, every fight contributes only the winner’s current skill, which leads to a total of N-2. For the maximum, let one gladiator keep winning so his skill grows steadily. The fight values then form an increasing sequence and the total is (N-2)*(N-1)/2.

Problem 2: Cyclic Shift Minimization

We consider reversing the sequence from N down to 1. The best value depends only on whether N is odd or even. If N is odd, the best value is 1. If N is even, the best value is 2.

Problem 3: Min Steps We start with X = 1. At each step, we can either double X or add D. We need the minimum steps to reach exactly N, or report -1 if it is impossible.

Think about doing only doublings first. After k doublings, we reach 2^k. Then we must cover the gap N — 2^k using additions of D. Additions can be amplified by doublings, so we check if N — 2^k is divisible by D. If it is, we use the binary representation of (N-2^k)/D to decide how many additions are needed, and convert higher bits into lower ones using extra doublings. We try all values of k such that 2^k <= N, and pick the minimum steps among valid cases.

Problem 4: Product Equal Sum We are given an array A of length N. A subarray is called good if the product of its elements is equal to the sum of its elements. We need to count how many good subarrays exist.

If all elements are at least 2, then the product grows very fast, so for each starting index we only need to check about 30 elements forward. If there are ones in the array, we handle runs of ones separately. For one, we extend to the right until it is only ones, and check if the sum matches the product at any point. So each run of once is processed in O(1). This gives an efficient solution that runs in about O(N * 30).

Problem 5: Could not solve. you can find my thought process in the screencast.

Here is my screencast https://www.youtube.com/watch?v=t3ZwRZA9ji8 PS: The pause from 18:00 minutes to 40:47 minutes was me dropping off my daughter to school.

»
8 months ago, hide # |
Rev. 2  
Vote: I like it +8 Vote: I do not like it

The rank list of 6 and 7 star participants doesn't contain those participants.