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

Автор chrome, история, 8 лет назад, перевод, По-русски

Привет!

Завтра в 18:00 MSK состоится TCO16 Round 1B.

Прочитать про TCO16 можно здесь.

И еще, количество участников ограничено, только 2500, и максимальное количество участников которые проходят на следующий тур — 750.

Предлагаю обсудить задачи после контеста.

GL && HF!!!

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

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

Are people who qualified in round 1A allowed to participate in round 1B?

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

    "All members who have not previously advanced – limited to the first 2,500 Competitors who register in the Arena" — from the rules linked in the post.

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

why no registration open yet?

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

How to do 1000?

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

    EDIT: My solution is wrong.

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

    My code failed in 1000. My logic is as follows. I find the max protection needed among all the positions not covered by any local shield and set the global shield to that value. After that I assign local shields greedily from left to right. When, at a given position, the current total protection offered is less than that needed, I find the local shield whose ending point is the rightmost among those active currently, and increment its value as needed. Can anyone please tell me whether this logic is wrong (if so, I made an implementation mistake)?

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

    I did ternary search on the amount the special shield is powered, and it looks like everyone did this. After that, you can sweep from left to right and use greedy with the addition of the simple shields, by using the one that extends furthest to the right.

    I unfortunately didn't think much about how it works — it was more based on intuition and the fact that the problem is supposed to be solvable quickly. Can anyone prove why this approach works (or give a counterexample)?

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

      Can you please tell me why we can't assign the value of the global shield greedily as I did (in my approach explained above)?

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

        Perhaps, you want to make the special shield higher than the minimum uncovered one.

        Consider n=3, h=2, t=1, and protection[]={10,1,10} and the two simple shields you have cover [0,0] and [2,2].

        Here, it's optimal to power the special shield with 10, and not use the simple shields, giving 10 cost overall. If I didn't misunderstand, your solution would give 1+9+9=19. Does this make sense?

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

        I had the same approach as yours, but I see our mistake now. If you have n shields next to each other one by one and low cost for supershield power, you'd like to use supershield once for all plants.

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

      I thought about that, but can it be possible, that values will be x, x, ..., x, x+1, x, ..., x, so we can not do ternary search on it?

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

        Maybe it's possible but recall that the parameters are generated by LCG, so are kind of quite random.

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

    I did ternary search on the value of the special shield. But need to set left boundary to the first position where there is a solution.

    First, need to sort intervals and remove redundant ones (e.g. which are fully covered by some other interval).

    When checking given value of the special shield, simply sweep through cells from left to right, checking for each interval start/end. Assume interval starts, then before the next interval you have to cover everything with the previous one. But you need to remember the intervals which were opened previously and how much money you have put in them. I used queue for that.

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

      Can you please tell me how you proved the function is unimodal (before ternary search)? Or was it intuition?

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

        Just intuition..

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

          It is actually not unimodal, simple example is when the cost of supeshield is 1 and we have to cover one plant — we can distribute the power between super- and regular shield in any way. What makes ternary search possible is that only the minimum value can be repeated by this function.

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

            "What makes ternary search possible is that only the minimum value can be repeated by this function" Can you please explain this part in some more detail? I was under the impression that ternary search can only be applied to unimodal functions.

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

              Suppose that the only value that the function can take more than once is the absolute minimum (which you are looking for), i.e. if f(a) = f(b), a ≠ b then f(a) = min f(x). Then you can just run standard ternary search and if the function ever takes the same value in 2 different points, you immediately know the minimum.

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

I think that they could have done a better job in setting point values for the problems. In my opinion it should have been: 300, 350, 1000.

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

Can someone explain me why this solution is incorrect?

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

    EDIT: Rewrote comment.

    The constraint "if len>=n" stop and return -1 applies to the original n, not the last number in the sequence (they never call that n). Not saying it was a misunderstanding; I just know I had a bit of confusion over this and had to reread a couple times.

    Others definitely also made this mistake, and 1e9 catches it as hellman_ said below, but even if you add a catch for "if (n==1) return -1;" you can still fail for example on 1162.

    1162->42->20->4 (now len>=n and you break)->16->17 (answer).

    I think this is where most hacks were from, but also some people in my room just used a bool prime[] array and failed on big primes.

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

      I had another related bug (and I think many others did too). The constraint applies to original n, so we need to check that sequence does not loop. I didn't do it, my thought was that "n will be small after few steps so does not matter". So I was hacked with 1000000000, which looped on 1.

      PS: maybe on C/C++ it would still pass, but I coded on python.

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

        It failed on c++ as well, I tested my own code before submitting on that with removing my check for loops, took 4.5 seconds, and then I hacked a couple of people using c++ or java with the same bug as you using 10^9

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

      It is not misunderstanding

      I think he just forgot to add a new variable for max len of sequence

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

      Oh, stupid bug :( Thank you for your explaining, I was thinking that something wrong with tests.

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

Is it rated?

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

Я правильно понимаю, что если я попал в волшебный список, то мне не нужно и я не могу участвовать в раунде 1C?

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

It seems weird to me that Topcoder is always so slow at updating the ratings on the website, I can't really think of any reason why it shouldn't be quite fast to just transfer the data from the applet to the website?? Does anyone know any explanation for why it's so slow??

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

This guy : saisumit has obviously cheated. No actions against him? He got to blue!

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

    leave it to karma

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

    Why downvotes? This guy solved 250 in 21 seconds and 500 in 47 seconds. See here too. Such a gifted coder!

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

    I just saw this post so i need to clear things a bit , First of all apologies , both arrogantidiot and zoomswk are correct but partially , as u can see this was my 3-4 serious contest on topcoder , i was there in my friends room when i saw the questions on his screen and thus coded them there only without knowing the fact( again my ignorance ) that topcoder judges on relative time unlike codeforces ,and that is when things went a bit haywire ,and unknowingly and unintentionally the following scenario happened , I would be more than glad , if u can provide some help on how to unjudge my problems .

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

      I am sorry, but I dont see why we are partially correct! If you dont know the rules, that's YOUR problem. I believe you can own up to the topcoder admins and get yourself off the leaderboard (with / without some penalty).

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

        thanx for the advice, but i have already sent a mail to topcoder before i actually saw your post. but again thanks for the advice and if u want anything else from my side u can message , i will surely ponder upon that

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

          I understand that you did it unintentionally, and it's great that you are trying to be responsible for the consequences. I don't know how TopCoder will react to this situation but you might be removed from the leaderboard, and the problem won't really be a big deal (assuming that you and your friend did not share solution ideas).

          I'm sorry for you and hope you understand my and arrogantIdiot's raising the issue, since it might affect other participants to some degree. :D

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

Seriously, can anyone prove the solution for hard? I made something like ternary search (with parameter -- number of expensive segments) and after walking in both directions as not getting TL. And was really surprised when got AC without any walking. Is that even true that f(i)-f(i+1) is not increasing?