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

Автор shef_2318, история, 9 лет назад, По-английски

Hi everyone!

I'm happy to announce you about the new contest organised by HackerEarthIndia Hacks 2016!

Just check out the prizes:

There will be 3 qualification rounds with 3 hours duration each. From each qualifier top 1000 participants will advance to the main contest, so the final is going to be a decent battle of 3000 coders.

The first qualification round is taking place on Sunday, January 3, 18.30 Moscow time. View your time here

The problems of the first round were kindly prepared by RomaWhite. As you might already guessed I'm the tester and editorialist. In my opinion this problem set is very nice because it requires more thinking than implementation, but on the other hand most of the problems are not very hard, so it will be a good warm-up for your brain after New Year celebration :)

In order to participate register here.

Important note: this contest has a partial scoring system and all the problems have subtasks. It means that if you don't know how to solve some problem you should try your best to get some partial solution.

Bye-bye and I hope to see you all participating and having fun :)

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

»
9 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

The contest starts in less than 2.5 hours. Good luck everyone!

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    Will there be editorials ?

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится +64 Проголосовать: не нравится

      You are red with black letter, why do you need one? ;)

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Editorials were added before the contest, but there are some issues with adding problems to practice again and editorials are unavailable :/ I hope admins will deal with it soon.

      Anyway feel free to ask questions and discuss problems here.

»
9 лет назад, # |
Rev. 2   Проголосовать: нравится +4 Проголосовать: не нравится

First four problems:

1) String Division
If the length of the string is less than 10, bruteforce over all possible ways of splitting the string.

Otherwise the answer is "YES" (split the string into four parts of lengths 1, 2, 3, length - 6)

2) Hungry Lemurs:

Try all possible final values of k, for each one i find it's closest multiple to n, call it v and the answer for this value would be abs(k - i) + abs(n - v).

3) Strange Function:

First sort the array in ascending order and subtract c from all elements of the array. calculate the current answer for this array, call it cur
Now, go through the numbers in descending order, Add 2 * c to the current element, update cur.
The answer will be the maximum value of cur
Updating cur:
Adding 2 * c to an element will decrease the difference between it and each element larger than it by 2 * c (therefore cur will decrease by 2 * c * (n - i) ) and increase the difference between it and each element smaller than it by 2 * c (therefore cur will increase by 2 * c * (i - 1) )
So cur = cur - 2 * c * (n - i) + 2 * c * (i - 1)

4) Permutation Swaps:
Consider pairs that can be swapped as edges, and positions as vertices. A number i can move to it's position in Q if there is a path between it's beginning position and it's final position.
I used DSU to solve this problem , after adding all edges, if there is a number whose position in the first permutation is in a different component than it's position in the second one, then the answer is "NO", and "YES" otherwise.

I would appreciate if someone could explain his solution to the fifth problem

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Any proof for the third problem ? How did you come up with that ?

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      First, subtracting c from all elements then adding 2 * c to some of them is equivalent to subtracting c from some elements, and adding c to others.
      The only assumption in my solution is that after sorting the array and subtracting c from all elements, the elements to which we will add 2 * c form a suffix.
      Proof:
      If we add 2 * c to the ith element and not to the jth element i < j this will affect the answer by:
      2 * c * (i - 1) - 2 * c * (n - i)
      However, If we add to the jth element instead of the ith , this will affect the answer by:
      2 * c * (j - 1) - 2 * c * (n - j)
      and since j > i, then 2 * c * (j - 1) - 2 * c * (n - j) > 2 * c * (i - 1) - 2 * c * (n - i) ,therefore it's better to add to the jth element, so the elements will form a suffix

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      Another way of looking at it: we need pairwise absolute difference for all pairs.So even if we sort the numbers we don't cause any change(since still the absolute pairwise diff would be the same.) So after we have sorted the data we want (assume 1 based indexing)..(let's see for first element )|a1-a2|+|a1-a3|...|a1-an| as data is sorted this is equal to (a2-a1)+(a3-a1)+...(an-a1).So we notice a1 is subtracted n-1 times . following similar process for a2 we'll get that a2 gets subtracted (n-2)times and added once(1st term of a1 series). so eventually we get a[i] is added (2*i-n+1) times. Now we can accordingly increase or decrease a[i] by c to suit our purpose of maximizing individual positive contribution or minimizing individual negative contribution of a[i],based on signs of a[i] and (2*i-n+1).

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can someone tell me how my naive solution got 100 points for the first problem ?
https://ideone.com/6eDaoc

»
9 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

By the way, the editorials are live now. And the problems are open for upsolving, too. Do not underestimate the power of upsolving a contest. (That is, if you failed to solve something!)

»
9 лет назад, # |
  Проголосовать: нравится +21 Проголосовать: не нравится

Are all the rounds online or is there any onsite round as well?

There is something called "PHASE II (OFFLINE)" in the contest website. Does this mean there will be an onsite for Algorithms track as well?

»
8 лет назад, # |
Rev. 3   Проголосовать: нравится +28 Проголосовать: не нравится

When can we expect prizes to be delivered to us? It has been more than 6 months but haven't received prizes yet.

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится +4 Проголосовать: не нравится

    They just keep on postponing the expected date. They always reply that it's in progress and will be delivered to you within next 3 days.

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    UPD: Today I got a confirmation mail from HackerEarth that my prize has been shipped.