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

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

Round 2 of the 2021 Facebook Hacker Cup is less than 48 hours away!

The round will begin on September 25th, 2021 at 10am PDT and will last for 3 hours. The contest can be found here.

You're eligible to compete in Round 2 if you scored at least 24 points in Round 1.

The top 2000 competitors who solve at least one problem in this round will receive a Facebook Hacker Cup t-shirt! We'll begin shipping out t-shirts by early 2022 or earlier, at which point the winners will receive emails with tracking information.

Furthermore, the top 500 competitors will advance to Round 3, taking place on Oct. 9th. Please note that all submission judgments will only be revealed after the round end, and that time penalty will be used to break score ties. More details about rules and other information can be found in the FAQ.

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

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

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

See you on the scoreboard! Good luck, have fun, and go win a tshirt!

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

Will there be a 6minute submission timer here too? And only 1 submission rule?

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

Hi, I am not able to update my competition profile. Whenever I click on the "Save" button, it shows a message — "Error performing query". Can you help?

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

Can someone tell how to increase stack size in Sublime Text-Windows

I tried by this comment but not able to do it correctly .. https://mirror.codeforces.com/blog/entry/94726?#comment-838535

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

    If you have an existing build, head over to

    C:\Users\username_other_than_public_and_default\AppData\Roaming\Sublime Text 3\Packages\User

    This is my build, you can paste it and change to whichever version of C++ you prefer:

    { "cmd": ["g++.exe","-Wl,-stack=268435456","-std=c++17", "$$${file}&quot;, &quot;-o&quot;, &quot;$$${file_base_name}.exe", "&&" , "${file_base_name}.exe<inputf.in>outputf.in"], "shell":true, "working_dir":"$file_path", "selector":"source.cpp" }

    If you want to make a new build, Tools -> Build System -> New Build System (last option)

    Paste the above build and follow the same process and save. Next time you build, you have to manually choose the new build, and then onwards Ctrl+B should work.

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

Why my input file had some stupid gibberish. I was not able to compile it.

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

It takes quite a bit of time to download the input, and i think my internet isnt slow.

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

Looking forward to when FHC actually employs the standard CF/CC/AC rules

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

Can anyone help me with the stack overflow error...I am unable to pass even the validation test case for problem B.

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

3rd time failed Facebook Hacker Cup(being able to solve problem).

2018: stack overflow in round 2

2020: started too late and didt pass to round 2

2021: can't copy 46mb file OMG

2022: stackoverflow because 1.5Gb isnt enough

2023: can't download input because my HDD has no 200Mb free space

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

Well, it was another Facebook InfiniteStack FastInternet HugeFiles Cup for me xD. Why the f**k did i wake up at 02:00 a.m. xD)))

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

What a shitty contest it is! So, many issues with downloading input and submitting soln files. Moreover , the problem statement for A is also not clear. Total waste of time!

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

this is a smurf account, but really had a bad experience with the stack thing even after figuring out soln in just 25 mins — 30 mins for B

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

The tasks were very pretty, and the contest was so educational. For example, I discovered that my stack size is 8 Mb) And also discovered how to increase it =). (Spoiler: pragmas didn't work). By the way, it is sad that there are so few only-output type contests, because I really like this format(.

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

Wrote solution for C1, submitted, passed pretests, made final submission.

Realised bug 5 minutes later while implementing C2. Compared fixed code with old code and output was greater by one in exactly one test case.

As expected, I FSTed in exactly that test case by 1. Took my rank from less than 150 to greater than 800. RIP.

(PS: I really, really don't like this format of checking. Too many ways to mess up from extracting to piping input file to stack overflows to whatnot, and the 6-minute-to-death timer for imposing this weird format)

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

Did anyone else used $$$O(S \cdot \min(n,m))$$$ approach for $$$C2$$$ :)

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

Just here to commiserate with everyone else that couldn't figure out how to increase Mac OS stack size above 10 MB :(

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

Imagine having AC code for the second problem but you can't submit because you have a stack size error in the last minute.

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

Can FHC consider changing the contest so that tests are run on a FB test server instead of on the contestant's computer? (Or have a validation input which can trigger max-stack-size issues?) Ran into stack size issues on B and my solution was fully correct (submitted for practice shortly after the contest ended).

Based on how many "Submission timer expired" I see on B, it looks like this was a very common problem: https://www.facebook.com/codingcompetitions/hacker-cup/2021/round-2/scoreboard?start=1350

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

I am very sure that my solution to Problem B was correct But my system doesn't allow that much memory which was required for test cases. (nlogn memory).

I tried a lot to somehow manage it but can't overcome the issue.

At least you can warn about it in this blog post .

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

Test in D were weak, greedy (wrong) solution that fails on my tests and bruteforce for small inputs passes. Maybe it was impossible to create good tests for such problem.

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

When I saw B I remembered the threads from the previous round of people complaining they couldn't figure out how to make the stack bigger in 6 minutes. (Since the stack breaking tests were in the BIG test). I was thinking people will complain again about this and was mildly amused.

Then to my surprise I see that there's actually a line test in the validation, how nice of the authors to do that, that will make people stop complaining.

Then to my ultimate surprise I come in the CF thread, and still see people complaining about the stack.

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

    You'd be surprised how many people we had submit clarification requests saying things like "Why did you make validation data so big for problem B??? It doesn't run on my computer!" lol

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

      do you know how to increase stack size for java? I have 8gb heap space in intellij still got stackoverflow.

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

        I use this thing called stack trick. You can change your main method to a different method like M(), and then this in your new main method (which just wraps your old one):

        Thread t=new Thread(null, null, "", 1<<28) {
          public void run() {
            M();
          }
        };
        t.start();
        t.join(); //you're going to need to mark your main method as "throws SomeException", I forget the name of the exception exactly, your IDE will tell you
        
»
5 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -27 Проголосовать: не нравится

Yo someone please tell me there's a clean way of doing C2 or else somebody ought to be fired from problemsetting.

My idea: you first shift up or down some number of times, then perform single remove operations on what's left on row $$$k$$$ (so same idea as C1). Let's assume we only shift up for now (down is analogous). I precompute the cost of each shift. The thing is, when shifting, in certain columns you might no longer be able to shift because there's too many cars and no room to keep pushing. Thus, for each column I compute the number of shifts after that column gets stuck and you can't shift it anymore. After a column gets stuck, the state of the $$$k$$$ th row will no longer change.

When we introduce spells, changing one cell only affects that column. Specifically, the number of shifts at which the column gets stuck could move up or down. So we use sets to find that, and range update operations on a segment tree to change the cost values.

Thing is, this is way easier said than done because there are quite a few cases to consider, and my implementation ended up being disgusting. Here's the code, don't even bother trying to understand it lol: https://ideone.com/iv4U5d

EDIT: Ok there are definitely cleaner ways of implementing C2. I still can't say I like the problem, but I'll cool off on it.

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

Huge congrats to Radewoosh for clinching Round 3 fourteen seconds before the end of the contest!

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

Seems there are a lot of possible solutions for B.

Mine is to just count the number of bridges on the tree but add a long cycle for each of the same frequencies, which I found very interesting.

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

    I tried the same thing but didn't have enough stack size for the main tests :(

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

    You can also count complete subtrees(ones where any node $$$n$$$ with a distinct color contained in the subtree, $$$n$$$ is also present in the subtree) then combine the sums from children with small-to-large merging.

    Similar problem: Link

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

    My Solution: Get LCA of all nodes v having same frequency. for ewach v,LCA pair do sum[LCA]++ and sum[v]--. This will activate edges between v,LCA

    Do simple dfs by adding sum[i] to curr at each point and when cur = 0 increment ans. O(NLogn) time, O(NLogn) space

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

    Yeah I did something similar. I constructed a graph with the following bidirectional edges :

    A. Real edges given in the input

    B. Edges from vertex i to i+N

    C. Edges from vertex i+N to j+N iff i and j have the same frequency.

    Now if a1,a2,a3..ak have the same frequency, only connect a1-a2,a2-a3... So that there are O(N) edges of type C. Aka construct trees of same frequency.

    Now just find the bridges of the graph in O(N+M), [M = O(N) here] and only add the bridges which are real edges to our answer.

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

    My approach (couldn't finish in time though) For each frequency, calculate the first and last discovery time of any node having that frequency and also the in_time and out_time for each node. Now for each node excluding the root, the condition for the edge between the node and it's parent to be removable is that there should be no frequency for which the interval [first_discovery,last_discovery] intersects with the interval [in_time,out_time]. This can be achieved using 2 segment trees and binary search.

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

      You can actually check if there are any intersections without segment trees and binary search.

      Let's observe that for each node U the edge between U and its parent being removeable only depends on the frequencies that occur at least once in the subtree of U. We're not able to remove the edge if there exists any frequency F in the subtree of U such that first_occurrence[F] < in[u] or/and last_occurrence[F] > out[u] , So all we really care about is minimum of first occurrences and maximum of last occurrences of all frequencies in the subtree.

      This can be done pretty easily in O(n). you can check the code here.

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

    Let $$$S_x$$$ be the set of all vertices $$$u$$$ such that $$$F_u = x$$$. We want to add a path from each element of $$$S_x$$$ to the LCA of the set. Just compute the LCA and for each $$$u$$$ in $$$S_x$$$ go upwards connecting $$$u$$$ with each element you find using DSU, stop when they are in the same component. To guarantee it will work you need to eval $$$S_x$$$ with lower LCA depth first.

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

why hackercup can't follow similar format like google codejam ? why this 6 — min timer and output file upload shit ?

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

TFW you attempt to solve C2 by writing code for the case where you shift cars up, then flip the board and run it again, but you forget to flip the updates too :(

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

Well, that was fun, thanks! :) Adrenaline. I guess Radewoosh has the same emotions :)

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

Screencast https://youtu.be/nGCeL0y2T1Y

Here's my heuristic solution for D. (passed 5 minutes after the contest end)

I want to focus on two types of elements. The first type is those that are not divisible by a number that is a divisor of many elements. The second type are elements that are far away from other elements (like 500 in a sequence 1, 2, 3, 500, 1000, 1001, 1002).

I put aside top elements of those two types. Greedily assign all the remaining elements. Then run knapsack on those few special ones.

how many special elements?

Anybody sees a way to break this solution?

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

D: If we have a set of $$$K$$$ numbers such that max number is $$$M$$$, and $$$2^K \gt K*M $$$ then we can choose two non-empty subsets with the same sum (pigenhole principle, pigeons <- subsets, holes <- sums).

For M=200000, K=23 works.

If N is small do bruteforce, if N >=25 it is always possible.
Use the following schema again and again:
1. take 23 smallest or random (both seems to work) untaken numbers
2. start generating subsets and computing their sum (stop when you detect two with equal sum).

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

These problems are good, but I just blow it in this round.

Problem A is my nightmare, I tried to implement it by DP, but failed from time to time. I then jumped to problem B, but cannot find any hint.

After one hour and half, I found I can use greedy in problem A, then I move back to A. However, there are two bugs and miswriting in my code and it spend another hour to correct it.

I submit the answer 2 hours 30 minutes, and I move on to problem B, but still cannot find any hint. Finally, I find problem C1 are much easier, so I jump to problem C1 in last 20 minutes. I thought I must do it before the end of the contest, so typed very fast, and made many silly mistakes.

When I correct all of the mistakes and try to download the full input, the contest has ended 5 minutes ago, and my final ranking is 2700+, a result that cannot even win a T-shirt. My answer just get accepted in the practice mode. I cried at last, very very sadly.

I really cannot accept my current result, I am too nervous, and I think I can do better. In order to prepare for this contest, I practice nearly every past round 2, and can pass most of them.

The most reason I failed in this contest is that I was too eager to win, since Facebook is my dream company and I want to behave well in the contest to get an interview. I am about to graduate this year and looking for jobs afterwards. That is my main reason. If I just do for fun, I can behave much better.

Afterwards, I need to move on, and delete my hacker cup experience in my resume. Thanks for this contest, I find so much to improve.

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

    Facebook is my dream company and I want to behave well in the contest to get an interview.

    I don't want to rub in your feeling but how well does one need to perform to get an interview? I'm still assuming that these results don't matter much unless you get all the way to the onsite finals.

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

      Last year, all T-shirt winners received an invitation in the T-shirt email to submit a resume/request more information on jobs at Facebook. I don't recall receiving any additional recruiting-related communication as a finalist (though I could be mistaken), but obviously, I can't say with any certainty whether finalists were prioritized for interviews/opportunities at Facebook in general.

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

    Cheer up! You don't need to be top 1000 or get into round 3 to get into Facebook. The correlation between interview result and codeforces rating is not linear and tends to be less as your rating rises

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

during this round i dowloaded input file to submit problem A but it contains wrong words not test cases and my time is expired, but after the round ended i download this input again but it contains correct format of test cases ,why this happened to me ??

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

I don't like the statements. I hope they will be shorter in further rounds.

A is unnatural and difficult to understand.
B is very long. In particular, why do you need this paragraph in the middle?

Mining is a ...

I would appreciate the diff between C1 and C2.
Finally, D is such a cute problem that you could describe in one paragraph... and you butchered it with an unrelated story. Making a nickname-related pun isn't cool if the original problem had nothing to do with it.

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

In the solution section of C1. There is a sentence "It cannot be better to combine both upward and downward shifts, nor to perform car removals before the desired shifts are done.". I think to combine upward and downward is possible to be better. For example

*X*X*X*X*X*X*X*X*X*X*X

X*X*X*X*X*X*X*X*X*X*X* // this is the k'th row

XXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXX **********************

We need to free up the second row

In this case one upward and 2 downward is the better solution. What do you think?

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

Thanks to authors for the contest!

Plus, thanks for maintaining a non-mainstream format, and working to improve it on top of that, like validation and pre-downloading large inputs.

»
5 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +11 Проголосовать: не нравится
  • Don't know if I should be sad that I couldn't advance to Round 3 (because I spent more time double-checking my solutions for silly mistakes than actually solving problems)
  • Or if I should be happy that I won a Hackercup T-shirt (because I spent more time double-checking my solutions for silly mistakes than actually solving problems).

 

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

Just a small suggestion: Show the number of test cases in input files so that I don't have to open large input files just to ensure that my code runs on all the test cases.

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

EDIT: Fixed, turns out the input is randomized each time

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

So happy to get a T-shirt in hacker cup. It's my dream since I started to learn CP last year. (^ω^)

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

Those with ranks 501 and 2001 would be so happy.

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

@Facebook Hackercup admins please disqualify the people who have not written a single line of code in their source code and just submitted the output file in both source code and output files. Like the person now ranked 1490 has not written a single code in his source code. Pls look into this matter and disqualify these type of people.

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

My rank with 10 mins left was 1900 something and seeing the rate at which it was increasing I was worried ill miss the cut by just a bit, with this motivation I debugged my C1 superfast and submitted it with 5 mins left on the clock. Felt extremely happy to see both passed and even more that I've won the T-shirt with a final rank of 1405 !!

Also, when will the T-shirts be shipped, I am too excited to wear it!

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

I solved problem B in a different way: Do an Euler tour (single occurring). Now your aim is to just count the number of such nodes whose subtree contains all the occurrences of a certain value,i.e., no value should be there which is in the subtree and outside that subtree as well. Subtree denotes a subarray of the flattened tree. Hence, you will have n ranges to query for and for that you can apply Mo's Algorithm to compute the final count of such nodes.
Time Complexity : n3/2
Code : https://ideone.com/hlTvaM

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

    That's a cool idea!

    In your code: you can also do updates of "moving L, R boundaries of [L, R] interval by +/-1 and maintaining array tot and variable cur" (using your notation) with this helper function:

    void update(const int what, const int delta, int& cur, const vector<int>& cnt, vector<int>& tot)
    {
    	cur-=(tot[what]!=cnt[what] && tot[what]!=0);
    	tot[what]+=delta;
    	cur+=(tot[what]!=cnt[what] && tot[what]!=0);
    }
    

    and using it by calling update(what is a[freq[EITHER L OR R]], delta is EITHER +1 OR -1, curr, cnt, tot);

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

I did something for B that i havent seen and i think it was a cool solution

Basically i used DSU on trees, so for each node i had the number of times each frequencie appears in its subtree, and i also had two more values: how many different frequencies the subtree has and for how many frequencies of that subtree the number of times it appears in the subtree equals the numbers of times it appears in total, finally to delete an edge coming to the current node from its parent you need these two values to be equal, because it means you are not separating any two nodes with same frequencie.

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

Does anyone receive an email from [hackercup2021-33527 at eventsatfacebook.com] about job opportunities? It requires me to login into a strange website so I don't know if the email is legitimate or not.

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

wrote about my experience in hacker cup 2021 in this medium blog article: https://shadek07.medium.com/facebook-hacker-cup-2021-experience-519f594bec7e

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

What will be the inscription on the t-shirts? "Facebook Hacker Cup" or "Meta Hacker Cup"?