Блог пользователя Pols_Agyi_Pols

Автор Pols_Agyi_Pols, 5 месяцев назад, По-английски

We invite you to participate in CodeChef’s Starters 214, this Wednesday, 26th November, rated for 6 stars (i.e. for users with rating < 2500).

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!

  • Проголосовать: нравится
  • +9
  • Проголосовать: не нравится

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Contest starts in 30 minutes.

»
5 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится -7 Проголосовать: не нравится

Contest Start Time is extended by 15 minutes ?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

I have a question regarding the problem VTAR .

What would be the answer for this testcase:

1
10 1
1 -1 -1 2 2 3 3 -1 4 4 
My Understanding:

Please help me know where am I going wrong in my understanding of the question? If my understanding is correct, then the above testcase can be used as a hack where most of the accepted code fails for the above testcase.

»
5 месяцев назад, скрыть # |
Rev. 6  
Проголосовать: нравится +1 Проголосовать: не нравится

I had a alternative solution to the last problem of Div 1 (with simpler implementation) sadly solved it few mins after the contest.

Beautiful subsequence also be solved in O(NlogN) with 2 pointers Submission

Almost the exact same idea as editorial, but since only consecutive good indices (pairs with N-1 distinct elemnts between them) matter, we shall do 2 pointers, just like a trivial problem of finding maximal good subsegment.

Say for a given good index L, we have [L....R] as maximal good subsegment, for this L. (i am iterating backwards in my 2 pointer approach)

To extend this for finding maximal good subsegment starting at L-1, we shall do this:

  • When observed, some new elements in the original array would have moved outside the first interval, I mean to say,the elements from (endpoint [goodidx[L-1]] to endpoint[goodidx[L]])
  • These newly moved out elements only would affect the good subsegment. (reduce the good subsegment size)
  • Meaning, if our subsegment of good indices (L-1,R) gets violated, it is because of any bad element (elements which do not have N-1 distinct in between its pair) who all occurences show up in the answer, (i.e, there exist 2 good index intervals, where this bad element occurs exactly once in both of them, so this bad element has to be picked by both the good intervals).
  • These newly moved out elements (bad elements outside first interval) corrsesponding mapped starting positions can be found out, and those good index pairs < starting positions only satisfy, and our R pointer of our 2 pointer approach can be moved accordingly.
  • For every movement of L pointer, say L to L-1, the new bad elements which may affect our current good segment, lies in from (endpoint [goodidx[L-1]] to endpoint[goodidx[L]]) , by amortized, the time complexity is $$$ O(N log N) $$$