Скоро Codeforces Round 1133 (Div. 1, Div. 2)! Регистрация здесь. ×

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

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

The Qualification Round of the 2020 Facebook Hacker Cup is less than 48 hours away!

The round will begin on July 24th, 2020 at 10am PDT and will last for 72 hours (3 days). The contest can be found on Hacker Cup's new competition site.

Everyone who solves at least one problem correctly will advance to Round 1, which will take place on August 15th. Please note that all submission judgments will only be revealed after the round ends. More details about rules and other information can be found in the FAQ.

Registration will remain open on the contest page until the end of the Qualification Round. Once you've registered, you may wish to confirm that the information in your competition profile is up to date. Starting this year, you may also choose a Display Handle for yourself there, to be displayed alongside your real name on scoreboards.

Look out for an upcoming announcement regarding this season's prizes as well!

We wish you the best of luck, and hope that you enjoy the contest!


Update 1: Facebook post announcing greatly increased cash prizes for 2020 can be found here, with more details available in the FAQ!

Update 2: The round has ended, thank you for participating! The scoreboard can be found here, and the solutions here.

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

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

Wait, There's no partial verdict? Like pretests passed?

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

    There aren't partial marks nor an exact equivalent to Codeforces' pretests. However, starting this year, there is a process of validating your solution before making an official submission, which is like a cross between sample data and pretests. There are more details in the FAQ, and you'll get to try it out soon during the qualification round.

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

Excuse me, but can people below 18 participate in the Qualification Round?

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

Time to create facebook account

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

Do we still have a 6 minute window between downloading test case then submitting our program?

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

Hi. I don't know if this is the correct place to ask this: I permanently deleted my Facebook account because I rarely used Facebook and I thought that I wouldn't need the account anymore. But now I want to participate in FBHC but I couldn't use my name or original email to sign up for a new Facebook account. Everytime I try to create a new Facebook account, I always receive this message:  Does anyone know how to resolve this issue? Is there any alternative rather than creating a new account with random name? (I couldn't open the FAQ because it requires me to login through Facebook)

Edit : I have not ever done anything that violates Facebook Community Standard (only account deletion which I think is a normal thing to do)

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

I would be really grateful if someone can explain clearly, the submission process in facebook hackercup? I am unable to understand it from the internet or the FAQ

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

Hope, there will be no karangreat234 in this round

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

I keep updating the display handle but it always resets to nothing whenever I check back.

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

Oops looks like I missed the round.

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

Is the system of checking solutions to codes similar to that at Topcoder in Facebook Hackercup?

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

    You'll need to write code to solve similar sorts of problems, but differences include the fact that you'll need to write a full program capable of processing input/output and execute it yourself. Please see the FAQ for more details, and consider practicing on past Hacker Cup problems to get a sense of what the system is like.

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

I have a couple of questions:

  1. Does the time penalty of a round affect the qualification of the rounds other than the next? For example, does the ranking/penalty from round 1 affect qualification to round 3?

  2. Is it possible to get TLE?

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    1. Each round is entirely independent.
    2. The only time limit is that, upon downloading the full grading input file, you must be able to run your code on it yourself and upload the resulting output file within 6 minutes.
»
6 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

$$$ $$$

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

Can I deactivate my account after I'm done with the contest?

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

I don't get it what the hell just happened?? I downloaded the input.txt file for D1 and funny I wasn't able to read the input... Refer this screenshot

Does this mean I won't be able to submit solutions having input files of similar size using current lappy?? Tagging LoneFox

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -45 Проголосовать: не нравится

In problem C , can there be multiple trees at same position ?

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

What does wrong answer indicates in validation phase ?

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

I have one serious doubt- Should the code I submitted also read a file and create a new output file if they will run my code on another testcase or just it should print output like Codeforces or Both or doesn't matter. Anyone please? Actually I have submitted the code that read a input file and create a new output file. Have I submitted it wrongly?

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

Look like you really need a fast enough network because the counter countdown while you downloading the testcase. I failed problem C because I couldn't download the whole testcase in 6 minutes, crazy contest.

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

    That's unfair. Maybe Facebook should improve the way to submit the solution.

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

    If you have any trouble during the contest, please send us a clarification and we can help. We do try to keep the input files as small as possible without sacrificing the integrity of the data.

    We hope to move to a format where we actually execute code for next year which will solve this problem once and for all.

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

      Yes, please make it like other coding competitions.

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

      Thanks for your reply, I'll try to send a clarification later. And it's really a good news if the contest run like other platform in future.

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

      We hope to move to a format where we actually execute code for next year which will solve this problem once and for all.

      Noooo, FHC is the last big contest with this unusual format, which sometimes forces you to look for a bug quickly in that 6-minute frame because something crashed or it's too slow. Don't make every contest the same :(

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

        +1, Google Code Jam lost a lot of its appeal to me once they changed the format to be like every other contest :(

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

        Ah, these are both interesting opinions, thanks for the feedback! We'd be interested in hearing any other things that you like about the current format compared to a more "normal" approach.

        The current format does have some downsides such as

        • limited data size

        • a general concern around unfairness re: different hardware and internet stability

        • time spent fiddling with files instead of coding

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

          I liked old Code Jam format because it allowed to have some fun.

          Like submitting everything in Excel.

          Or racing for the top of languages used leaderboard (hard-core players would deliberately fail Rounds 1A & 1B to get more languages in).

          Or just looking at what crazy languages did people use and their submissions.

          Or just solving the problem in two parts in two different languages if you really wanted it (say in the first part you wanted to use C++ STL, but for the second part you wanted to use Python long arithmetics).

          Or if you really need it, you can even use multi-threading to get just a bit more performance.

          The current format doesn't limit you in anything, it's basically just use your computer to solve this problem, in whatever way you want without limiting your tools in any way. When Code Jam used this format, it had this unique feeling for it, which it lost when it became exactly like the other contests. Which in my eyes, was a shame.

          The biggest downside to this format I see is Internet stability/speed. But that can easily be addressed by distributing tests in advance in a password-protected archive. When the you start the timer, you could just reveal the password. IPSC has been doing this for years.

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

        It's possible of course to combine code execution with the same "one-shot" approach. As a random idea, imagine getting full feedback (we tell you whether you got AC/WA/TLE/PE/RE), but if you don't get AC the first time, you have 6 minutes to try to get AC :)

        Open to suggestions!

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

          What would TLE mean here? Bc what if my solution is actually supposed to take approx 3 minutes (bc my mind is small and I can't come up w/ intended solution). Then how do I like avoid the TLE verdict. Also maybe some progress bar showing time left on cases would be good (if we're submitting to online instead of local). Finally, maybe don't include AC or WA. Only the other answers, bc well that's another added layer abt this contest -- we don't know if sol is correct till grading. Tagging Errichto, eduardische, and ffao from above thread for their much greater experience than mine.

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

      Please do so. My computer got a blue screen when I tried to submit for Problem C (I was copying and pasting to stdin which I probably shouldn't have done). Nevertheless, I ended up missing the submission window which was a bit disappointing.

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

    If I needed more than 6 minutes to download 30MB, not advancing in FHC wouldn't be on top of my life issues list

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

B

Edgar and his younger brother Alfred are alchemists in search of the legendary Philosopher's Stone

via the Law of Equivalent Exchange

Fullmetal Alchemist fans LMAO

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

I have a question: I didn't add #include <string> in my source code submission for problem A because it is not necessary in my computer, will it be ok or it will be Compilation Error ?

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

Is TLE not possible in the qualification round (if I managed to submit the output and source file within 6 minutes timer) ?

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

do we need submit source code in text?

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

in which extension we submit the output file,i have tried in .py extension but it gives invalid file based on the extension(.py)

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

Why do facebook keep 6 minutes window? How does it help?

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

I think there should be a change in way of submission.For C and D1 and validated my code, but couldn't submit in time, just because wasn't able to download the file. It's unfair. No motivation to try D2 and fail again.

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

This really very frustrating I solved C and when I downloaded the large test file my computer froze and I was not able to submit in time and now I cannot submit, it really feels bad

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

shouldn't the submitting time be more than 6 minutes. I solved D1 but couldn't submit in time as it has taken more than 4 mins on my local machine.

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

    If you can't submit in time, because your program is too slow, then you shouldn't receive any points. It's the same as on any other online judge, on which you would receive a TLE.

    Any problem (at least in the qualifying round) has a solution that runs in less than 10 seconds. Together with the overhead of downloading and uploading, you should be able to submit any problem with 5 minutes still on the clock. 6 minutes is really generous.

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

I created a new FB account for Hackercup. But it keeps getting disabled. I uploaded my phone number to get my account activated 2 days ago. Today, my account got disabled again and it is asking me to upload my photo. Is this happening with anybody else? And is there no other solution than to create a new account everytime this happens?

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

Can we have different login-registration process for FB hackercup from next year onwards? Something independent of FB profile. I think lot of people (including me) are either creating new account or enabling disabled account they don't use anymore.

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

Can anyone please clarify my doubt regarding time limit for running of a problem. Like in codeforces for some question it is 1 s and for some it is 2 s as there is no mention regarding this on the hackercup's problem page.

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

Everyone who solves at least one problem correctly will advance to Round 1 Does that mean I will surely qualify if I solve only one problem? Is there any benefit of solving more than 1 problem other than improving rank in the leaderboard.

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

Are there any constraints on the time complexity of the solution? For example here on CF. I can get an idea that expected solution should be in O(n) or n(log(n)) or so on.

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

Problem C input file was big (>27mb) that it took more than 6 minutes to download it with my super-fast internet speed. Yikes!

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

Does validating solution also tell us if our code gives correct output on the input file? Might be a dumb question to ask but this was my first HC and I have never participated in codejam.

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

Well, where are the time limits? :3

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

LoneFox Sir, I ran into a problem during the Facebook Hacker Cup. I validated my solution on Problem D1: Running on Fumes — Chapter 1. However, when I downloaded the final test case, the text file was filled with random characters as below,

input file

So I ran out of the 6 minutes time in which I was supposed to submit the output. I would request you to look into the problem, and if possible, restore the access to that problem. Thank You

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

can anyone tell me why it is showing presentation error ? how should i print the output ?

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

anyone had problem with stack size in d2?

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

Suggestion: have password-protected zip file. Contestant downloads it, and then indicates he would like the password. Start the timer then.

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

Hi.In problem D1, I tried running my code locally on large input file(~11MB) but my PC froze and I had to forcefully shut it down.By then, the submission time of 6 mins had already expired.Is there any tool using which I can run my codes on large input files online? Thanks in advance

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

    Sounds like you used too much memory (too big memory complexity), and you ran out of RAM. That usually also means that your runtime complexity will be to big, and your program will not finish in time, even if you rent a server with >100 GB RAM. You need to improve your solution.

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

This is weird testing. In D2, my local system got hung on this large input. And timer expired. -_-

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

    Same thing happened in my problem C. Input file was 30mb. Downloading it took 5 minutes. After running it my local system got hung on this large input :/ I mean why can't they have a system similar to Google Codejam for example? :/

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

    If you're not talking about downloading speed, most likely your solution was just not efficient enough. Treat this as TLE or MLE in a normal contest.

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

    Same here. My stack was not huge enough to work with a graph with $$$10^6$$$ nodes(
    Increasing the stack size didn't help, so sad

    After the 6min timer I replaced DFS with BFS and now I have the answer, but who cares now..(

    To authors: Isn't $$$10^5$$$ or $$$2 \times 10^5$$$ vertices enough? I believe it would hurt people much less than it actually does.

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

      I'm a bit reluctant to talk about the contest while it's still running, and I think we all should at least a bit. You're still giving information about the solution and an unfair warning to some before starting the 6 min.

      Nevertheless, I'll do a similar thing and explain your questions with my opinion.

      You're right and it's another challenge, not exactly related to the problem. But those things happen and now you can consider it in the future. Or maybe you can find a proper way to increase your stack limit that'll work and use it later. I had this problem in previous years and I learned how to do it and now I didn't need to change anything.

      For the part for the authors, I don't think that they could safely assume that it'd be okay to have lower limits. I'd be pretty sure to solve it in slower time complexity but in an optimized way that it'd work pretty fast in the general case.

      Also, I think I'd be comfortable with another few testcases that would take several seconds. I would've given it a shot before finding a better solution because it's not required to solve that to pass the round and trying to squeeze it to fit time limit sounds more fun.

      But more importantly, people that couldn't find a solution would try it and again I'm pretty sure that some non-negligible portion of them would fit in into time window.

      If I were an author I'd do the same.

      And finally, that number of vertices wouldn't solve the problem for most. I think you still should do something different to be not challenging your stack limit.

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

      Exactly .. why not 2*10**5 ???

»
6 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится -61 Проголосовать: не нравится

For those who solved D2, how you would rate it in codeforces?

What would any of you rate the other problems? I solved everything up to D1 and I would rate:

  • A: 1000-1200
  • B: 1400-1500
  • C: 1600-1700 (maybe more? it actually took me a while but after solving it, it seemed easier).
  • D1: 2100-2200

Errichto I saw you solved it super fast, what rating would you give D2?

Edit: Does anyone agree with my ratings? just curious

»
6 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится -31 Проголосовать: не нравится

.

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

So where can I run that input file to get output?? Please tell me if you know...

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

I use VScode for CP, but for D1, the input file was so large,my system did not print anything.Timer expired.My query is how to deal with these large files for the other questions?

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

how do i run a c++ program having array input of size>10^5,because i failed to submit the facebook hacker cup question d1 sol because my pc failed to compile/run their input files.please suggest any online compiler which takes such a large in put file

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

.

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

Why can't Hacker's Cup use a separate account? My account has gotten "deactivated" twice in the past two days and it's simply annoying. It's not like us programmers even use the account in the first place. We usually end up deactivating it so why bother go through the trouble.

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

    Welp. Now my Facebook account is deactivated because "it violated community guidelines" (just a reason to force me to upload a picture of myself, I surmise, as it's hard to violate any community guidelines when all you've done is submit problems to Hacker's Cup) and I can't submit anything. Another reason why Hacker's Cup should use separate accounts.

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

Is there supposed to be a time constraint for each problem?, since the problem statement didn't explicitly mention it. Or does it only check the correctness of your output file?

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

I am getting a presentation error while submitting my code. How to remove it. What is format of the submission file?

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

Guys can you please tell me why rank doesn't change even after i submitted my first solution?

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

    Your score and rank will update as soon as you make a validly-formatted official submission. Please confirm that you're making a full submission (not just validating your solution), and that you didn't receive a Presentation Error verdict due to submitting an improperly-formatted output file.

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

By the way, the new system looks very nice and clean! Probably the nicest looking competitive programming website right now?

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

Can someone please help me to solve "Presentation Error"? Even Though My code has same format as mentioned in sample test cases.

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

The increased prize is awesome, but what are coordinators' thoughts on cutting it down to like $18k or something so that you can spend the extra $2k on tshirts for top 500 or something like in previous years?

As someone who probably isn't going to beat Gennady this year, it's inspiring to have the more realistic goal of earning a shirt instead...

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

Lol,

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

in order to minimize spread of COVID-19, we maximized number of transfer connections you need to take

Is this how USA deals with coronavirus? Would explain a lot :P

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

Screenshot-207.png Any Idea how to fix this first they asked for my phone number and then my photo and once I uploaded it shows this LoneFox wjomlex?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -26 Проголосовать: не нравится

I tried everything. but is showing presentation error. can anyone please help me ? Case #1: YY YY Case #2: YY NY

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

In problem D1, there is a test case of 999946 size of array which cant be process on my system. What to do? I have tried declaring vector/array globally.

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

how to overcome stack overflow error? I can't get any output now. How can I increase the Stack-size in c++?

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

The Input File for D1 was too large, I think my solution was correct, it got validated, and I ran it on 96 cases (basically repeating the validation input several times), but when I ran my code on the main test cases, it crashed my Sublime IDE, and I could not submit, despite everything.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -24 Проголосовать: не нравится

Why can't they have normal input and output, like some pretests or something? Why do they put contestants through stupid things like "download this" and "validate that". Just take the damn source code man.

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

    Exactly, it kinda frustrating, our source codes, would be perfectly right, but, we're not able to get points, because of all these formalities.

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

    There are benefits and drawbacks to both, with pretests the codeforces servers have been seen to sometimes have a long queue recently, although I suppose 72 hours to submit on your own time would make it less of a big deal.

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

    I personally prefer submitting code (because I find it more convenient), but the cool thing about downloading the file is that you can use any language and libraries you want (like you could implement your solution in Mathematica or use numpy or something else), or even combine multiple languages or have a manual step in some rare circumstance.

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

If the person hasn't cheated and has passed the validation as well as full input file ? Are there any chances that he will get it incorrect after the contest ends ?
I mean the full input file are the total test cases ?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -48 Проголосовать: не нравится

Errichto Could you please explain how to solve C and D2? Was able to do D1 but have no idea on C D2

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

Video solutions to all problems, for people who are interested.

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

The contest has ended, and I placed 191 on the leaderboard. Here are my solutions: https://www.youtube.com/watch?v=yxG_zMZ34uc.

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

Adding my name to the list of people supporting a change in grading system after I got WA on D1 (pushing me out of 1st place in the round) because I accidentally ran my C code on the D1 input :p I just tested the source code I uploaded with my submission on a new input file and passed the tests. Obviously, it's entirely possible to upload the wrong file on CF, just as it is to run the wrong program in FHC, but in those contests you have the chance to resubmit (usually without penalty) after your answers are absurdly wrong and you fail the first test. Unfortunately, the validation system doesn't deal with this edge case, since I had the right file pulled up to deal with the validation input but somehow ran the wrong one on the real tests.

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

    Thankfully I didn't have any issues this time, but I very nearly uploaded the input file instead of the output file. I'm also a strong supporter of the 'submit your code' system instead of the 6 minute timer running things locally as well (preferably with single-testcase problems as well). It just makes everything easier for the competitors.

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

    We intentionally have a different T for each problem to help alleviate this to an extent (so we can tell if you've uploaded output for a different problem as opposed to just egregiously wrong output for the current problem). It's unfortunate that your code is successful on both input formats XD

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

      I suspect the issue was that my D1 input included few or no huge input values early on; there was a case with 100,000 small values before any massive inputs appeared. As a result, since C reads a different number of values per test case than D1, my C processed a large number of tests with small values of N that corresponded to gas prices in the D1 tests; as a result, it was able to finish processing the appropriate amount of tests based on the D1 input.

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

    I was screwed because problem C's input file was ~30 MB and downloading that took away 4 minutes. I replaced my input.txt with the downloaded file, then stupid Codeblocks crashed because I keep input.txt open in Codeblocks. Froze my system for 2 minutes. No time to run and upload files.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -74 Проголосовать: не нравится

Don't work for Facebook bruh, unless you care about the money part

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

I accidentally submitted my template code in problem C but my solution passed :facepalm Will it affect final standings?

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

Is it possible to solve the problems after the round is over? (And submit them for practice.)

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

For problem D2 I submitted a rather naive brute-force solution which I think could run in O(NM) worst case. All my solution does is use a priority queue to sort by current cost and then by fuel remaining. Then it just tries all the states in that order, and fills up on fuel if possible. It runs on my computer in around 15 seconds, but I feel like tests could be constructed to make it take much longer.

Would anyone mind looking at my submission and see if this is the case?

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

Can anyone help me figure out why this code for D1 has a runtime error on CodeBlocks before I increased the stack size to 256 MB? Does it have something to do with my least_cost set?

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

Does someone have a more detailed explanation for how to solve D2 using Centroid Decomposition? It's not super clear to me how to relate the centroid tree to this problem at all and the explanations above are kind of short.

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

    I did something like this :

    1) We need to calculate dp[i], which is the minimum cost to reach vertex i from A. C[i] = 0 can be replaced with a large value (infinity) to allow fuelling in any node.

    2) First we build the centroid tree of the given tree and for each node u maintain the distances to all it's children in a sorted order in a vector (say dis_child[u]).

    3) Maintain a priority queue of active nodes from which we'll be relaxing the dp values. The priority queue will be sorted accoring to dp[i] + c[i] values. Initially the priority queue will only have node A.

    4) Now we need to pick the best node ( say x ) from the priority queue and relax those nodes which are reachable from x and have not been visited and make them active.

    5) Step 4 can be done using the centroid tree. For a node x, travel to it's parent (say p) in the centroid tree and let the distance from x to p in the original tree be d. Then we need to remove the nodes from dis_child[p] which are at a distance of <= (m — d), relax their dp values and make them active, if they've not been visited before.

    Total Complexity : O(NlogN).
    Here's my submission : Link

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

      Awesome, thank you!

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

      I did the same thing but in a simpler way. Initially, A will have some set of active nodes (nodes at distance m from A) in the priority queue, now as you remove the nodes from the priority queue you'll be unlocking further nodes (for examples nodes at distance m + 2) and you'll add them to the priority queue. For doing this, I will maintain a list of nodes that will be unlocked when A will be able to reach some distance x. In this way, we can avoid using the centroid tree.

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

Hi wjomlex, I have been unable to view the friend leaderboard since the contest ended. It just keeps loading without any result. Is this a known issue? I'd be happy to DM my FB username if it's useful for debugging.

Thanks!

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

Mildly interesting: this problem is nearly identical to D1 (even in flavortext) except for the fact that you don't have to fill up your tank entirely and you pay for gas relative to how much you get.

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

Hi all, I wrote a simple O(N) deque solution for facebook hacker cup problem D2, I'm wondering if many other people knew there is a simple O(N) solution, or perhaps I should write a post about it if people would be interested? The editorial suggested O(NLOGK) rather than O(N)

Thanks :)

@robertkingnz code link: https://www.facebook.com/async/codingproblems/download/submission/source_code/?submission_id=1611307992378413

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

    Me too! my code

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

    Yes, describe please.

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

      @errichto, my girlfriend is very impressed you replied to my comment since she sees me watching and learning from you on youtube :) Maybe we should collaborate someday, I want to make a game-theory website and platform. Also i'm very strong on Full Stack Development so I could help you with web development or I could sponsor your video sometime :)

      My code runs in 7 seconds using PyPy which i was happy with since python is usually a bit slow :)

      I used an increasing deque called "q", that contains increasing (i, cost) pairs. 'i' represents the ith value in the path from A to B, cost is cheapest cost to get to i. If there were no subtrees hanging from the path, we could delete all the code below the line "k = 0". However, if there is a subtree from a node in the path, we iterate the best costs (costs_below yields the best cost at each level of the subtree as needed), from these subtree costs we build another ordered deque called "better", that also contains (i, cost) pairs.(this time we insert right to left instead of left to right). The idea is we can fold this "better" deque onto the original "q" deque (pivoting at the ith node (merging to maintain sort order by 'i' value)). We then merge the two deques together, we only want the best values from each. However, the trick is that this merge still gives us O(N), we will never need to pop more than H values from 'q', where H is the height of the subtree. This is because worst case our queue 'q' has increasing values from ~ i-H to H. (think folding subtree back onto the path, it will only overlap at most H). So the cost of the last few lines of code that fix the queue is the same as the cost of traversing the subtree, which is O(N) on those nodes, so the overall complexity is O(N).

          path = get_path()
          visited = set(path)
          q = deque([(0, 0)])
          ans = -1
          i = 0
          for i, node in enumerate(path):
              best_cost = q[0][1]
              if i == len(path) - 1:
                  ans = best_cost
              if i - q[0][0] == M:
                  q.popleft()
              c = costs[node]
              if c != 0:
                  while q and q[-1][1] >= best_cost + c:
                      q.pop()
                  q.append((i, best_cost + c))
              elif not q:
                  break
              k = 0
              better = deque()
              for j, cb in enumerate(costs_below(node), 1):
                  best_cost = q[k][1]
                  if i + j - q[k][0] == M:
                      k += 1
                  if cb != 0:
                      new_cost = cb + best_cost
                      if not better or new_cost < better[0][1]:
                          better.appendleft((i - j, new_cost))
                  if k == len(q) or (j + 1 == i - q[k][0]):
                      break
              if better:
                  q2 = deque()
                  while q and q[-1][0] >= better[0][0]:
                      q2.appendleft(q.pop())
                  assert (len(q2) <= j+1) # <----------- proves O(N) !!
                  for vi, vc in merge(q2, better):
                      while q and q[-1][1] >= vc:
                          q.pop()
                      if not q or q[-1][0] != vi:
                          q.append((vi, vc))
          print('Case #{}: {}'.format(case_num, ans))
      
  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Yes,share your idea pls.

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

Can anyone explain what are the updates being carried out in D2 while using segment tree?

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

    Hey, suppose the path from A to B is this-
    A-C-D-B
    Now D has a branch from it, D-E-F
    Suppose we know min cost to reach each vertex from A (except B) and we are now going to calculate the min-cost for B.
    From B, C and E are at an equal distance and F and A are also equidistant from B. So from both these pairs we actually only need the ones with min (cost_to_reach + cost_of_refill). So when we are at E, we will update the segment tree for C's position (taking min of C and E) and when we are at F, we will update the segment tree for A's position (taking min of A and F).
    I hope it helps.

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

I submitted NlogN solution to C, but it didn't gave output on their testcases. Is it due to so many recursion calls increasing stack size? Please if someone can look into it and help.

It's frustrating. Thank you :)

Submission Link

It did pass their initial testcase check.

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

I have a short MIN-HEAP solution to D1 (with code) that has a conversion to D2 (which I didn't really have time to code).

I go from right to left (end to start) and I maintain a min-heap containing elements that had their cost distance from B already set, if you refuel at their position. I DelMin from the heap, and I go M indices back in the array, and then I move forward, setting the distance to all the elements until I encounter an element already in the MinHeap. I finish when "M indices back" reaches the first city. This works because the elements with already set distance from B (which means they were inserted in the heap) are contiguous from an index i to N.

An example of the first two iterations — the heap starts with only N with distance 0, and then it's popped, we go M back, and the cost of all the last M elements is now set as their cost. Now you get DelMin = (i,cost). You go to index i-M and update all the elements until you reach index N-M.

Code for D1:

D2: If anyone actually got here and wants to know the conversion to D2, just ask and I'll explain, it's simple enough.

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

    pls explain your idea for D2.

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

      Edit: I found a small problem. I'll correct and re-edit. I know how to correct, but it might be annoying.

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

      OK it got accepted! Yahoo! I debugged and found some errors and at the end it was for the best because now the explanation will be much simpler.

      In my solution to D1 I set the cost to all not-set elements from index i-M to i. The generalized idea is basically instead of index i-M to i, set all not-set element with distance from B of i-M to i (and then it's an exact generalization of my solution to D1). More specifically if the element popped from the heap (v) can reach v at distance K, then set the cost of all the element from i=K...dist(v).

      To understand the code though, I need to explain what I transform the graph to ( In the end this transformation big transformation wasn't needed at all, and really all I needed was the distance to A and to B, and I actually have lots of redundancy in my code, but it's already implemented and I'm not about to change it xD) :
      I transform the graph to an array A of lists L=A[i]. (this is the part I wasn't in the mood to do). For the sake of understanding, imagine the array A going left to right (A to B) and any list A[i] going from top to bottom.

      I look at the path from A to B as an array, where each cell in the array has a rooted tree (the subtree branching out from a node in the path, that doesn't include other nodes in the path). Then, since there is no point to refuel more than once in each of the these trees, I transform each of these trees to a list L, where at L[d] I keep the node with the minimum cost at depth d (of course the list is only as long at the tree's depth).

      The code: