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

Автор Errichto, 11 лет назад, По-английски

Hi. I want to invite you to HourRank 6. The contest will take place tomorrow (exact time) on the HackerRank platform. The duration is exactly one hour. I think that both beginners and experienced participants will find problems interesting for them.

There are problems from me and from forthright48. I want to thank Radewoosh for helping me with preparing problems, and for testing. I also thank malcolm, wanbo and Shafaet for testing and the technical help.

Limak needs you! I wish you great fun and no frustrating bugs. Looking forward to seeing you!

Besides fun, top 10 will get HR t-shirts. Good luck.

WINNERS

  1. Endagorion
  2. LayCurse
  3. riadwaw
  4. I_love_Tanya_Romanova
  5. tabasz
  • Проголосовать: нравится
  • +67
  • Проголосовать: не нравится

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

Why do you do this?
Both contests at the same time on the platforms with almost the same name :)
Is it some kind of a strategy to reduce the amount of participants from competitors?

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

Contest will start in two hours. Remember to hurry in other contests if you want to win them all today.

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

This time I would really appreciate feedback from lower-rated participants. How hard should be first two problems? It's hard to prepare four problems and give something interesting for everybody.

btw. for each problem you can find an editorial by clicking "Editorial" above the problem.

»
11 лет назад, скрыть # |
← Rev. 4  
Проголосовать: нравится +5 Проголосовать: не нравится

My big congratulations to all who solved the last problem. Endagorion has the same solution as the intended one (you can check the editorial) but with two times shorter code . And LayCurse solved it so amazingly that I want to describe it here. We will binary search the answer.

So, for the fixed value of the expected value dp[N][M][0] (N boys didn't dance, M girls didn't dance, 0 pairs danced) we want to check whether it's too small or too big. Now we can iterate backwards over O(N·M·NM) states and easily calculate values of an array dp[][][] (storing expected values), without an extra array for probabilities. Because we know the (assumed) expected value of the situation when a pair is upset and we must start on the next day. You can find find LayCurse's code here.

  • »
    »
    11 лет назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится 0 Проголосовать: не нравится

    Didn't manage to do that in time, but solved got accrpted last problem with iteration of this dp until TL.

    Is it possible to create test that will fail my solution?

    BTW, what is the 10th test? It was only test that gave WA on 5k iterations

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

    I might suggest a way to improve binary search solution by removing the binary search :). Let's assume dp[N][M][0] equals to some unknown X. Now in all formulas for dp we can use X instead of dp[N][M][0]. Thus dp[i][j][k] will be of the form A[i][j][k]+ X B[i][j][k]. The only thing left is to find X from equation X = A[N][M][0] + X B[N][M][0] which is trivial. Essentially binary search tries solving exactly it.