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

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

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
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится +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?

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

    I've talked with both platforms a moment ago. They are both cool about setting dates to avoid collisions but now it is too late to change anything about tomorrow. I hope it won't happen in the next month.

    Besides, you have half an hour of HE-Easy before HR-HourRank. I'm sure some people will try to compete in both. And after the end of HourRank there is still Easy going on. So, why won't you try both?

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

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

»
8 лет назад, # |
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.

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

    Problem-set was nice. Good job.

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

    I read first 3 three problems. Problem set was perfect for a participant like me. Solved first problem(equivalent to div 2A), implemented O(n^2) approach for second problem(Div2C) and passed few test cases in third one.

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

      Read the editorial for C. You will be surprised :)

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

        Now i am sad. :( Submitted C with just an wild guess (didnt have much time after solving B) , felt happy with the bonus 15 points in contest time , and now i see handling only one case could give me full points :/

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

    Nice problemset, thank you. :) faced some problem implementing binary search in second problem,managed to solve it in 52 minutes.

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

    Fine problemset! For my opinion the first two tasks should have had a little lower level, but for me they were interesting :)

    I always prefer tasks as third on contests like this. Good task, with nice short solution :)

    See you on next round !

»
8 лет назад, # |
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.

  • »
    »
    8 лет назад, # ^ |
    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

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

      It's not hard to come up with a test with the biggest answer and it is 1 30 0.1. The 10-th test was 1 30 0.0997. Your solution was intended to be a reasonable brute force. It must work well because r ≤ 0.1. It wouldn't work with r close to 1.0 though (or n = 1 and m bigger than allowed in constraints).

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится +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.

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

      Doesn't sound similar to the intended solution but again we have two arrays. Will there be some simple relation between them and ones in the intended solution? But still, nice observation.

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

        Well... It seems that A is expected number of dances if we assume that when bad situation happens we immediately stop. And B[i][j][k] is the probability that we will run into a bad situation. So the result A[N][M][0]/(1-B[N][M][0]) becomes pretty much like yours :)

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

        Actually, this is exactly my solution.