Comments

This needs more upvotes. Thank you for writing this!

We will try to release the editorial within this week.

No this contest will be unrated.

It's been updated on the contest landing page now. :)

Thanks for notifying. The issue is now fixed :)

My solution for div1C is a little different. I know this is an old problem but I found it really interesting.

Let's graph the problem. Let's assume each cyclic shift happens in 1 second. Plot time along the x axis and the absolute difference in positions in both arrays for each value along the y axis.

Observe that there can be only two possible values of the slopes of the lines in the entire graph — +1 and -1. The line for a particular value will have slope equal to +1 if the position of the value in that instant's cyclically shifted array b is <= its fixed position in array, otherwise its slope will be -1.

Moreover it's easy to notice that for a particular value, its slope value changes a maximum of 2 times in its graph.

So we can maintain two range minimum segment trees with lazy propagation range updates for slope value = +1 and -1, each of which store the minimum y-intercept value at each integer instant from x = 0 to n-1. Then for at any given x, the answer is $$$ min \ ( i \ + \ minimum \ y-intercept \ of \ slope \ = \ +1 \ at \ x \ \ = \ i \ ,-i \ + \ minimum \ y-intercept \ of \ slope \ = \ -1 \ at \ x \ = \ i \ ) $$$

Total complexity is O(nlogn)

My submission: 57004696

(I've shifted the entire graph by 1 unit to the right to avoid using a segment tree with 0-indexing in my submission)

We spoke to the Amrita officials. It was not an issue.

How to solve div2 F/ div1 D?

Don't really know how to

Someone make this for Amrita too? :3

From BITS-Pilani, Hyderabad Campus:

hyderabadi_coders: hit023 free_hit c.rakesh27

On isaf27 → Mail.Ru Cup 2018 Round 1, 8 years ago
+10

Yeah looks pretty similar to majk's solution above. Thanks :)

On isaf27 → Mail.Ru Cup 2018 Round 1, 8 years ago
+1

Thank you :)

On isaf27 → Mail.Ru Cup 2018 Round 1, 8 years ago
+10

How to solve E?

Really enjoyed the problems today. :)