neal27's blog

By neal27, 6 months ago, In English

Hello, Codeforces!

We, Algorave, have curated a Solo Practice Contest in the gym, Coding Challenge Alpha IX — by Algorave. The level of questions is medium. This is for anyone who loves giving contests and solving problems. This contest will be of most interest up to Expert rated coders, but I would also like to invite Div. 1 coders to participate as well. For anyone who wants to practice or just wants to go through the problems can register for our contest here. Hope you will enjoy solving the problems!

A massive thanks to:

Contest Details:

We hope that this contest, regardless of your background, rating and result, will increase your exposure to competitive programming and make you better than you were yesterday. Have fun!

Note: You can also register for the contest while it is going on. You may want to check out our group for past contests.

glhf:)

UPD1: The registration has started!

UPD2:

Congratulations to the winning contestants!

  1. TheAbbie
  2. pasricha_dhruv
  3. Kira_1234
  4. lord_Inosuke
  5. Electro_Valkyrie

Congratulations to first solves as well!

UPD3: Editorial is out! Thank you all for participating, see you soon!

UPD4: Contest is made private, you can access the contest with this link.

Test cases have now been set visible to the participants.

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

»
6 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

As a problem tester, I really liked the problems and highly recommend everyone to participate in the contest !

»
6 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

excited

»
6 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

As a problem setter, I had a great time working on this contest with the team. Hope everyone enjoys solving the problems as much as we enjoyed creating them!

»
6 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

Loved the problems, highly recommend everyone joining the contest!

»
6 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

As a problem setter, I would recommend everyone to participate in the contest.

»
6 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

I wish I will be one of the setter in Alpha X :)

»
6 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

As a tester, really enjoyed all the problems!! Hope you all like it too!!

»
6 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

Hope you all enjoy the problems! Have fun and do participate :)

»
6 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Looking forward to the participation

»
6 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

Excited!

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

How to do E ? I got to the idea that if number of occurrences <= 2 or in AP, we need 1 operation, otherwise 2. But the order of operations also matters. how to deal with that ?

  • »
    »
    6 months ago, hide # ^ |
     
    Vote: I like it +6 Vote: I do not like it

    if there exist at least 1 value of x such that they form AP, the answer is distinct cnt, otherwise its distinct cnt + 1

  • »
    »
    6 months ago, hide # ^ |
     
    Vote: I like it +6 Vote: I do not like it

    Only first operation restricts us from removing all occurrences of some value at once, after that you can always rearrange in sorted order and remove any value directly since all values together can be removed as they are in AP.

    so answer is atleast "number of distinct values in range", but you may not be able to remove all occurences of any value in first operation, so depending on that, answer will be distinct + 1 if you can't else its distinct.

    now distinct is simple offline problem DQUERY

    whats left is checking if any value in the range has all its occurences in AP of index.

    this is offline too like you can do sweepline and find if any value has all it's occurences in AP inside range.

    say right[i] stores rightmost index such that all occurences of arr[i] from i to right[i] are in AP of index, and then we sweep and maintain a value which covers query using segtree while sweeping.

    Python Code

»
6 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

How to solve C?

Also a request to maintainers to let us view other's solutions.

  • »
    »
    6 months ago, hide # ^ |
     
    Vote: I like it +6 Vote: I do not like it

    It's not hard to observe that the optimal path is a piecewise straight line, connecting the top of the towers, where all interior towers between two points lie on this piecewise straight line or below it. This gives the optimal path a convex hull structure as any valid line on the path would only bend right or remain straight (ignoring the first line which connects (0,0) and first brushed tower/point on the hull, which is trivially necessary).

    Proof

    So, the number of towers that Spiderman needs to brush is nothing but the number of points on the upper hull where we keep the collinear points too.

    You can now refer to this article on CP Algorithms, to implement the algorithm to find the upper hull.

    My AC Submission: 345958377

»
6 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Any idea/hints to solve B? tried a lot unable to solve

  • »
    »
    6 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    you can convert multiple modular multiplication operations into a single one. So all you need to know is the value k such that a[i] * k = b[i] mod (n + 1). Note that n + 1 might not always be prime, so you cant apply fermat's theorem to find the modular inverse, use extended gcd algo instead to find k for any one valid index and check if its same for all the indices.