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

Автор eduardische, 10 лет назад, По-русски

Напоминаю, что в воскресенье в 00:00 по Москве состоится второй раунд Facebook Hacker Cup 2015. По результатам первого раунда, 732 участника продолжат борьбу. Во втором раунде, 100 лучших пройдут в третий раунд, а 550 лучших получат футболки. Раунд продлится 3 часа. Для участников, задачи будут доступны здесь, а таблица результатов тут.

UPD: Раунд закончен, опубликованы предварительные результаты. Катоффы по ним:

  • Проход в третий раунд: 55 очков (A+B+C) с временем ≤ 2:21:53
  • Майка Facebook Hacker Cup 2015: 10 очков (А) с временем ≤ 30:23
  • Проголосовать: нравится
  • +67
  • Проголосовать: не нравится

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

Я бы сказал, что завтра в 0:00. И добавил ссылку на задачи и таблицу результатов.

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

    Спасибо, добавил. Хотя лично я фанат японской нотации времени, где считается нормой указывать времена в формате 26:00 и.т.п. для сохранения ассосиации к одному дню (например, ТВ или бары).

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

      В такой нотации не очень понятно, когда заканчивается один день и начинается другой.

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

        А зачем это понимать?

        Я не знал, что это японская система нотации времён, но в расчётах сам мысленно всегда так и соображал: "ага, этот раунд начнётся завтра в 24:00 и закончится в 27:00". Понятно, что для большинства людей в моём часовом поясе раунд, который длится с 00:00 по 03:00 воскресенья, это именно продолжение дня субботы, а не раннее начало дня воскресенья.

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

Did they send notification by email this time? I didn't receive it...

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

Hmm contest starts 5am here.. Not sure if I should go to sleep or stay awake (・_・ヾ

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

Good luck, everybody! May we have a smoother round than last time :)

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

    Is ranking going to be online during the contest? Is it going to be frozen before end of the round? When will we know the official results?

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

      The live (pre-judgment) scoreboard is available to everyone during the contest. It never gets "frozen" (in the ICPC sense) because you don't actually see the judgments until the end of the round. The scoreboard should be revealed shortly after the end of the round.

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

        Why can't people not competing see the problems? Can't think of any cheating argument or anything else. Would make it more exciting as a spectator to be able to see what problems people are solving.

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

          Agreed. We're going to make sure this is available for next year. We unfortunately don't really have any time to do development on the system during the contest season because we're busy with the administration of the contest. But I intend to make a bunch of improvements for next year.

          I just made a post with the problem statements: https://www.facebook.com/hackercup/posts/904095026289353

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

            One thing I would like to add if possible divide a problem into two set, like gcj one having small test and another large. Otherwise it is painful to do small mistake which you can not correct after 6 min.

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

            Could you reupload the image for the last problem (Fox Socks) in bigger resolution, please? It is possible to read it, but it is quite problematic.

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

        Could you share an estimate on when the results will be available? Does it make sense to wait or should we go to sleep?

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

    Last problem: does the queries mean:

    From bin Ai to Bi or from bin Ai to bin (Ai + Bi-1) ?

    Edit: nevermind, I got response from organizers. It was Ai to (Ai + Bi — 1)

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

I want to express my gratitude towards the authors of the last task. I believed I love segment trees so much that I can code them really quick. You showed me how wrong I was.

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

How to solve the 25 points problem?

I've tried a greedy approach by picking up the string that will decrease the cost and in case of equal the one that has less similar suffix strings. But unfortunately I got a bug that I couldn't discover before the 6 minutes passed :(

Is my approach correct?

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

    I used dynamic programming (for trie nodes in DFS order), but I don't know if a greedy solution is possible.

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

    I did a dynamic programming, after you sort the strings: best[i][j][l], the minimum cost if you put the i-th string, you already have j other strings, and the cost of adding it is l. When you add another string, you look at the last one added and it's cost l, and see if by adding the new string you'll change the cost, so you can take this into account (since the cost of a string i is determined by the previous and the next in the sorted array)

    It ran in in about 3 minutes.

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

    Greedy approach:

    1. start with all possible one character prefixes as S

    2. until you have K prefixes do steps 3-4:

    3. remove shortest prefix X with most direct childs from S

    4. add all prefixes starting with X and one character longer then X into S

    5. print sum of prefixes lengths in S (K oldest if you have too many)

    Special cases:

    • if prefix has only one indirect child there is no reason to remove it

    • if prefix is only direct child of its parent use its parent length for step 5

    • use word+'#' so every word ends in leaf. just make sure 'abc#' prefix length is 3.

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

Обожаю дебагать деревья отрезков в 4 ночи :/

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

Seems like last problem needs only accuracy, accuracy and accuracy :(

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

    It also requires some interesting insights (imo). When I first saw it I thought it was a segment tree problem with a bunch of complexity thrown in for the sake of making it take longer.

    It took me quite a while to realize that you need to have two trees (or a tree with two sets of values) for the odd- and even-numbered bins to handle the fourth operation. Figuring out what to store in the tree to handle the first two operations was interesting too.

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

Why not N ≤ 100000 and M ≤ 100000 on Fox Socks? My computer couldn't run 1000000 in time...

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

    Maybe to avoid bruteforces ran on supercomputers...

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

    My laptop is more than 5 years old, and it processed the input in time in 1 thread. Either you need to write faster code, or your computer is too old. Still I didn't expect the input to consist almost entirely of max tests.

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

I won't say, how I am impressed by the innovative and interesting task D, but am I the only one, who wrote log N solution per query, and I was able to get answers only to 11 of 20 tests due to big constant of segment tree and slow notebook?..

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

    :) I ran my solution using 3 parallel threads, and got all cases solved in ~5 minutes. I guess you could also use parallelization to squeeze through.

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

How to come up with last problem?

  • Hmm, lazy propagation can handle this one

  • This one too

  • We can use it for this problem either

...

Lets merge all of them to make single problem and see who codes faster?

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

    Oh it could be worse...

    Why not use a tree (in preorder numbering) instead of a line?

    Why not make the tree dynamic?

    Just 4 queries? Pfft, add several more — with min/max conditions, some bitwise operations for good measure, both updating and counting ones

    and increase the limits on N, M.

    'tis a dangerous path no problemsetter should ever tread!

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

      You forgot about creating cactus out of tree by adding one more edge. :)

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

      You forgot about dynamic cactus graphs.

      // Whoops, it means I'm not the only one who thought about this :D

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

    I think the interplay between the 1st and 4th operations is a really interesting part of this problem. I agree that when I first saw this I thought it was a chimera, but there are subtleties at work that make it much more than the sum of its parts.

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

      If that is the only interesting part of this problem, why not get rid of queries 2 and 3? There are already dozens of problems on queries 1, 2 and 3.

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

        I think 1 and 2 together force a bit more consideration as to what gets stored at each node in your segment tree.

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

          If this is the first time such problem appear, you are correct. But unforetunately, FBHC is not the first one, nor the second one to come up with such problem (・_・;). Given that this problem is painful to code + already appeared on the Internet, I think many competitors felt like (╯°□°)╯︵ ┻━┻ (at least 36 people downvoted your 1st comment).

          Also, about the 3rd problem, isn't it too old too? DP on tree, at each vertex you need Knapsack DP to select K vertices from subtree. I solved it many times already. And it was quite straight-forward to reduce to that problem. (˘_˘٥)

          Overall, so far I haven't seen any interesting problems (all are old, only more complexity is added). Since next round is to select top 25, I hope the quality of problems will significantly improve.. ヽ(•‿•)ノ

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

          How about the fact that the array was circular? Doesn't add much to the problem.. just the need to split the query in 2.

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

      If we omit the last operation (which is really just a few more lines of code), it becomes one of the first hard problems I ever encountered in a competition. Around 4 years ago. No, it's not very original. Not to mention it's practically impossible to code it in time if you don't know all the catches already.

      If it's really necessary to give a DS problem in a contest like this, then you should've omitted one type of updates and significantly decreased the point value.

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

Last problem, I finished implementing my code when there were 10 minutes left. My code passed first 4 pretests and failed the last one :(

What a great feeling.

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

    I found like 10 different bugs that didn't change answer on first 4 pretests, so if it makes you happy you can't really know how close you are to answer based on that :P

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

Furthermore, problem C has a tricky case from using DP approach if K = 1. If not considered separately, the code might output 0 instead of 1. However, no case with K = 1 was present in at least two people's inputs.

No comment on whether this is good or bad, but I hope K = 1 case wasn't present in only some people's inputs.

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

    Yeah I also noticed the same. My input also didn't have the case.

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

    You're right that there was no K = 1 case. That was an oversight on my part. If we had it, it definitely would have been included in everybody's files.

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

Can someone share tests/answers? I'm adding a training to the Gym. I have my answers for A-C, but not sure about them.

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

I want to say that quality of tests is... well, I don't want to use the word awful.

In my input for task C there wasn't any test with K = 1. Are you serious? At least there should be following test:


1 2 1 a b

I'm sure that 10% of AC solutions for this task will handle this test incorrectly. Techincally, the answer 0 here works (since we choose some word and empty prefix is enough to pick it), but there was a remark in the statement regarding non-empty prefixes.

It is such simple idea that there should always be testcases attaining maximum/minimum possible values of constraints...

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

    Well, yes, on the other hand one might argue that it's good to not penalize contestants who solved the task correctly and forgot to add one if statement.

    The only absolutely necessary requirement is to either give this case to everybody or give it to no one. Out of four people who shared this information, no one has it, so hopefully no disaster here.

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

    Yes, I was astonished to discover that test case is missing...

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

    Most of the participants who didn't consider this special case in their solution would just manually fix it once they see "0" in the output. So IMO missing this case is not a big deal.

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

      10% in my comment is my estimation for the number of contestant that do not pay attention for zeroes in their output. Actually I think this number may be even bigger... That really affects the final scoreboard.

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

    I've added the test to the Gym's version. After rejudge the number of solvers reduced from 52 to 33.

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

Looks like YuukaKazami (Tom Chen) have submitted his solutions for R1 instead of R2 and thus got zero points instead of first place. What a pity.

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

    I thought there could be some victims when I saw all T=20...

    I have some suggestion to FHC:

    1) That kind of errors could be prevented if FHC does more sanity check on the output file. The output of Round 1 A is positive integers, but Round 2 A is yes/no.

    2) Change the number of test cases between the problems: Why T=20 for all problems?

    3) Even if sanity check found output file is wrong, the font for notifying this is not bolded or underlined, so there is some possibility to neglect the message. Some red-background box, like notifying problem statement changes, will work.

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

      1) Yup. For next year I plan to always include the sample cases as the first K cases in everybody's input. Then we can confirm that you at least match the sample output. That'll catch this along with a slew of other problems, like:

      • Not formatting "Case #X:" properly. We get a lot of "Case #X" and "Case X:".
      • Outputting the wrong number of decimal places
      • Strange whitespace. A bunch of people were tab-separating things in the output rather than space-separating.
      • Uploading your source as your output and vice versa (in the amusing case where your source has the same number of lines as the output should have).

      2) Yeah, I intend to change this too.

      3) Agreed. I'd like a more eye-catching UI for things like this, and for clarification announcements. The current UI is at least 4 years old.

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

        Any progress on "For next year I plan to always include the sample cases as the first K cases in everybody's input."?

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

          As far as I noticed, they are always included but somewhere in the middle because tests are shuffled.

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

            I came here to ask the exact same question! I think the sample cases were also included in a random order last year, so it seems they didn't implement this, which would be a really good change. I guess I should have bugged wjomlex personally when I got to see him :p

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

              Yeah, currently the samples are always included, but mixed in. We took a different approach of catching more PEs before they happen. If you have the wrong number of cases in your output, or the wrong number of tokens (contiguous non-whitespace characters) in a case, or your first tokens aren't "Case" and "#xx:", you'll get a formatting error right away and you'll be asked to resubmit.

              The idea of matching on the samples up front was largely to prevent PEs, not WAs, so if you have the right format, but don't match the samples, we won't say anything.

              We finally changed our legacy "every problem has 20 cases" thing this year (that was very silly), and we stopped requiring a specific number of decimal places for real values.

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

You increased number of T-shirts by 10%.

I suggest you to increase the number of the advancers by 10% too.

Just an idea from the guy on the 110-th place.

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

    There are 550 Tshirts :)

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

    Good idea, johnasselta took 111th place :]].

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

    +105 :)

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

    BTW, there are people in top 100 with wrong answers for this test case. Of course, I won't mention their names, because this is both unethical and unfair, but increasing the number of spots in Round 3 may actually be a good idea.

    In case you think, that I am complaining just because I didn't made it to the Round 3 — I'm truly not. I support fairness, that's all.

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

      Would it be fair for those who legitimately got to top 100?

      They want to compete among 100 participants as rules say, not among crowd.

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

      Before my submission, I had thought of this case.

      Then, I checked if there were "0" in my output, and opened the input file, searching for " 1".

      There were no such cases.

      Therefore, I ignore this situation, and submit the "wrong" code.

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

Can you give an estimate regarding the T-shirt shipment timing? It's not really a crucial thing right now, but I'm kinda worried about them getting stuck somewhere in the process. Smooth round by the way, I'm glad there were no technical issues this time.

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

    I'm going to change address in 5 months. I don't know if I should enter my current address, since if T-shirts does not come in 5 months, I'll lose it..

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

      I had the same issue a few times and the easiest solution for me was to send the T-shirts at my parents address (which changes an order of magnitude less often than mine).

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

    I'm not sure we have an estimate at the moment. I would say message me in a month and we should have a better idea then. The T-shirt logistics are one thing that I'm not really a part of.

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

      Hi, I recently figured out that my address was incorrect and I fixed it like 10 minutes ago.
      Wasn't it too late?

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

Did you notice to ZhengJie rank 101 ? his total time is 2:21:54!! Just 1 second more than rank 100. Is it unfair or we should call him so unlucky person ?

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

    And what is unfair exactly?

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

      I remember that in ICPC World Final 2013, they gave a bronze medal to rank 13th just because of tiny difference in total time with the rank 12th.

      There was a debate on this here

      Anyway, I think it's not unfair if they accept all participants with total time less than 1 minute with rank 100.

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

        ICPC and FBHC are too different contests, why do FBHC organizers need to care about the decisions of ICPC organizers at all? This is not a common practice, I never seen this kind of "additional prizes" anywhere except ICPC, where all rules are weird (e.g. in Asia regionals, last year & the year before that, there was rule that in each of Singapore & Hong Kong, only 1 team can advance to WF).

        There are lots of reasons why we should not accept participants with 1 minute more:

        • Just because they are a bit unlucky, now top 100 have to fight more people in order to advance to top 25.
        • It's not fair to the guys with 61 seconds slower. Why did you choose the 60 seconds cutoff, why not 10 secs, 30 secs, 45 secs, 90 secs, 120secs...
        • Normal actions that organizers should take is to follow their rules. If they break the rules once just to let some guys with few seconds slower (note that in this case, there're no technical issues like last round), how do we know if they will follow their own rules in future?
  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Bad luck "only"...

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

For Fox Socks, the gap between the 4th and the 5th sample testcases are quite huge. I failed all the sample testcases on my first run. Luckily, the first four sample testcases are small (N=5) and I can debug them. I fixed several mistakes and managed to get the first four sample testcases correct, but the last sample case is too big to debug with. Can't get the last sample correct until the end of the round :'(

Anyway, I'm still qualify to Round 3. Yeay!

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

    Nevertheless, correct output on last sample wasn't a proof the program correctness. At some moment (with some combination of bugs) I had all samples passing, but program was still giving wrong answer on some obvious cases with n = 2.

    The best idea for this task was to start with writing naive solution (implementing what is described in statement), checking that you understand complicated input format correctly, and only then writing the full solution and stressing it with a naive.

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

I was very lucky for the T-Shirt rank 550.

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

can anybody tell me how to reduce time complexity of my code for the problem Autocomplete Strikes Back

(http://mirror.codeforces.com/gym/100587/submission/9562793)

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

    recur() doesn't modify "vector<int> y", so it should be "const vector<int> &y" to avoid copies. Furthermore, recur() is called repeatedly with same parameters, so you can use memoization.

    Also, for your own sake, use an editor with proper automatic indentation, makes the code much easier to read.

    diff: http://pastebin.com/6shUwb1f

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

Can someone enlighten me please; I see the following pattern common amongst many AC solutions submitted for problem #2: all_critical, eg. @ http://attachment.fbsbx.com/hackercup_source.php?sid=369011793270735

  • why is it necessary to +1 here: sum = 1;
  • why must the sum be divided here (and why is the term to be divided 1 - notsele[i] ?: dp[i] = sum / (1 - notsele[i]);

Is this popular approach different from what the editorial note explains @ https://www.facebook.com/notes/facebook-hacker-cup/hacker-cup-2015-round-2-solutions/1051224511560116 ?

Thanks

  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится +8 Проголосовать: не нравится
    1. You have equation like dn = c0·d0 + c1·d1 + c2... d2 + ... + cn·dn, you can't calc d_n using it itself, but you now know that dn(1 - cn) = c0·d0 + c1·d1 + c2... d2 + ... + cn - 1·dn - 1
    • »
      »
      »
      10 лет назад, # ^ |
      Rev. 6   Проголосовать: нравится 0 Проголосовать: не нравится

      Explanation posted as top FB comment to official editorial:

      We can reduce the time complexity for "All Critical" to O(20^2) by computing the infinite sum in a different way, without worrying about precision and L.
      Let E[n] be the expected number of playthroughs to get n critical bars.
      E[0] = 0
      E[n] = Σ[0 ≤ k ≤ n] C(n,k) * p^k * (1-p)^(n-k) * (1+E[n-k])
      We select k critical bars which we get (we got them in 1 playthrough), the remaining (n-k) we don't get (we will get them eventually in E[n-k] playthroughs).
      This formula is recursive since there is E[n] on both sides of the equation, but this can be easily solved resulting in:
      E[n] = ((1-p)^n + Σ[1 ≤ k ≤ n] C(n,k) * p^k * (1-p)^(n-k) * (1+E[n-k])) / (1-(1-p)^n)
      E[20] is the answer
      

      My question:

      In your equation, why is it C(n,k), and not C(20-(n-k), k), since you will achieve (n-k) critical bars in E[n-k] playthroughs, but in your 1 playthrough, you can select k out of the remaining 20 (ie. total) &mdash; (n-k) sections of that song?
      
»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Как долго футболки идут из калифорнии в Питер?

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

Yay! Received my T-Shirt today. =D

(Classy of Facebook to use FedEx delivery by the door. ^^)

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

    Eagerly waiting ! :D Haven't received mine yet. Haven't got any response lately from them either. :/

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

Just a small clarification in 20 pt problem . In the editorial , we need to calculate upto 20 powers of p and 1-p but these may become so small that P(s,i) may become zero which infact is not exactly zero. This leads to all P(s,i) values to become zero. How to overcome this?

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

    You scared me dude. Because of your post this blog appeared in the recent actions. After reading "Round is over" I thought I've missed it.