Unofficial Editorials January Cook Off

Ohk so lets say that elements from 1 to i-1 and its opposite side n-i+1 to N are arranged in an order .So lets say N=6 ,i=2 so we consider that a[1]<a[2] and a[5]>a[6] and lets say that we know the minimum swaps required to do this arrangement ,then we can calculate it for i=3.

So dp[i][2] indicates the minimum number of swaps required to make array great for indices 1 to i and its opposite side ,dp[i][0] denotes minimum value if i and N-i+1 indices are not swapped ,similarly dp[i][1] denotes minimum value if i and N-i+1 are swapped.

So i want to calculate dp[3][0] ,i can use dp[2][0],dp[2][1] as since i know that now values upto 2 are arranged ,i just have to check for 1 pair of element(3,4).Now i need to check if i can use dp[2][0],so just see if a[2]>a[3] and a[4]>a[5],if it is then i can use dp[2][0],similaarly do for dp[2][1](however swap a[2],a[5] and then check)

Similarly we calculate dp[3][1] but now we swap a[3],a[4] and then check the same things,(we do 1+min(ā€¦) as this swap contributes thaat 1)

1 Like

I had been busy the whole day, so i didnā€™t even solve the third problem, let alone writing editorial.

About official editorial, i donā€™t know.

Including you @vijju123 :stuck_out_tongue:

You just made 1718 people feel like genius with that xD

2 Likes

Yeah i was wondering how could so many people solve so fast

1 Like

Nice one :smiley: @abdullah768

Ohh Sorry, I meant official editorial.

ā€œAfter first three digits, only the pattern ā€œ2486ā€ repeats till end of the numberā€.

This is not true. It can also be all 0, e. g. 2, 3, 5, 0, 0, 0 ā€¦

I have already mentioned it

See edge case mentione above :slight_smile:

We will soon provide the official editorial. So sorry for the delays :frowning:

1 Like

For 18 out of 90 valid d_0, d_1 combinations d_4=0. Thatā€™s 20%. You call it ā€œedge caseā€? :slight_smile:

Yeah, i just called it Edge case. :stuck_out_tongue:

My choice :wink:

The actual reason to mention it as edge case was, that i forgot to mention it earlier.

Got it bro thanks :slight_smile:

@eugalt - The fact here is, the pattern followed by that case is different which cannot be handled by current algorithm. Plus, how many people were able to catch the case at first try? Not 20% I am sure :slight_smile: