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

Автор osmanorhan, история, 3 года назад, По-английски

Hey all,

We are excited to invite everyone to the Quora Programming Challenge 2022, a free programming competition open to participants from around the world*! The competition will take place on February 5, 2022 from 14:00 to 18:00 (UTC + 00:00). We had a successful challenge last year with great participation and positive feedback for the problems, so we’re excited to do it again this year!

Quora (https://www.quora.com/) is a platform to ask questions, get useful answers, and share what you know with the world. In this contest, we include some problems inspired by real-world challenges that Quora engineers faced building and growing the product. In addition to competitive programming-style questions, there will also be some machine learning problems. We hope that this contest will be fun for everyone!

You will be given several algorithm problems and a few machine learning problems.

  1. Algorithm problems: These are competitive programming-style questions that have strictly algorithmic solutions. It is possible to achieve a full score on these problems.
  2. Machine Learning problems: These are problems around machine learning concepts. Scoring is problem-dependent, based on a scaled accuracy metric. It may not be possible to achieve a full score on these problems.

The problems were prepared by Quora employees including KhaledRezk, vlchen888, Myungwoo, Hwan Seung Yeo, Ryan Cheu, and me. They were tested by gafeol, huikang, and many other Quora employees.

The top contestants will be able to win the following prizes:

  • 1st place: $3000 USD
  • 2nd place: $2000 USD
  • 3rd place: $1000 USD
  • 4th to 10th place: $200 USD
  • 11th to 20th place: $100 USD
  • Top 100 places: Quora T-Shirt

Our recruiting team will also be reaching out to top participants for their interest in interviewing for roles at Quora. We recently became a remote-first company, so you don’t have to relocate to work with us.

Hope to see you at the contest!

Register here by February 3, 2022 16:00 (UTC + 00:00): https://www.quora.com/careers/challenge.

For any feedback or questions, please comment on this post or email: [email protected].

*Except for excluded countries. Full details, including the dates and rules of the competition, can be found here

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

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

Great initiative

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

Great, but Cuba isn't an available country :'(

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

Hi all, I participated in this challenge last year. I got an interview and a shirt from the challenge.

I am currently two months into my new grad role at Quora. This is me with the shirt.

There are three of us are who are hired from the interviews from the competition, with a few more in the pipeline.

These are the last year's problems for reference, obtained from this Codeforces comment.

Feel free to reach out if you have any questions!

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

    On what basis are participants divided into div 1 and div 2? I did not find any such preference during registration.

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

      It was more like session one and session two, held at different times with different questions. Participants could choose to participate in either or both of the sessions. The intention is to make it more convenient for participants of different timezones.

      This year we decided to have only one session, and they share one prize pool.

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

Is there somewhere we can submit solutions to last year's problems?

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

    We will not provide a venue to submit solutions to the last year's problems. However, when we invite the participants to try out our contest environment nearer to the contest date, we may feature an easy problem from the last year.

    You can refer to comments shared by other participants for some clues on how to solve them. Some of them may have shared their code too, and you can compare your code with theirs.

    For ML problems, it is difficult to compare and see if your solution works because it involves a very customized checker and hidden datasets. You can refer to my solutions, which were pretty high scoring for the ML problems.

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

Why are people from balkans not allowed to compete?

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

Upcoming Practice Session!

Registration will be open until February 3, 2022 16:00 UTC, so it’s not too late to sign up! We will be sending out the login credentials and instructions to access the contest platform shortly after the registration closes.

As a reminder, the challenge will take place on February 5th, 2022 14:00 — 18:00 UTC.

To help you get familiar with the platform before the contest, we will be holding a practice session on February 3, 2022 18:00 UTC to February 4, 2022 18:00 UTC where you can login to the contest platform using your login credentials, and try out the example problem. The example problem is not representative to the difficulty level of the contest, but hopefully this would be helpful for you to get used to the input / output mechanisms that will be used in the contest.

If you encounter any issues, please reach out to us at [email protected].

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

Programming challenge will be held on February 5, 2022 from 14:00 to 18:00 (UTC + 00:00).

Don't forget to participate!

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

What are the level of problems according to codeforces rating?

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

    Hard to tell, there are easy to hard problems, as well as ML problems integrated into challenge

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

Will the real contest be held in same website as practice round?

If so, where will be able to see the standings? (as there was no standings in practice round)

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

Thank you so much for the amazing problems. Can we get something like an editorial after it ends?

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

I CAME TO WHINE

HOW THE FUCK DO YOU WRITE DCHT WITH ROLLBACK?

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

    Test are weak, my solution with copying cht for every children got 100 lol

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

    You can use HLD technique and have $$$O(n \log^2 n)$$$ solution.

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

      I suppose that we need keep cht for every path?

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

        Yes we have a list of chts and when we go down on a light path we make another one and add it to the end of the list, when we are done with that subtree we can just pop it. When we go down on a heavy edge we don't add anything. For every node we always use the last added cht.

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

    You can use heavy light decomposition, maintaining O(log n) dynamic converx hull for chains from current node to root.

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

      I got sick at the end so I wrote some decomposition of hulls which passed but it's O(NsqrtNlgN) at best considering the set's constant factor it should be a little more still it's fucked up that this passes.

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

    I tried persistent Li Chao tree but it ran out of memory. I wonder if it's possible to get it within bounds...

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

    I used persistent Li Chao tree: https://codeforces.net/blog/entry/68363

    This contest was the first time I have ever used this data structure on any problem, LOL

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

    You can write Persistent LiChao tree. I actually wrote it but failed to get AC due to some formatting issues while reading input in java (subtask 2, file 21 and subtask 3, file 49).

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

    Isn't there a simple and straightforward $$$O(n \log^2 n)$$$ solution? If you have vertices in dfs order, build a segment tree on it and store a CHT in every vertex. Now you only need to be able to add a new line (car) to a segment (which is adding a line to at most $$$\log n$$$ CHT's), and do point queries where you take the best value from every CHT on the way to the corresponding segment tree vertex.

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

    I simply saved the changed values on the Li Chao Tree and then rollback. The complexity is O(nlogn)

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

tourist (Gennady Korotkevich) while submitting the last point on task to get 100.0 points instead of 99.0, that's was incredible remontada.

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

How to solve Xuora?

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

    Case work (n = 4k, n = 4k+1, n = 4k+2, n = 4k+3)

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

      Can you please explain, how will you find the (m — n) numbers.

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

        I didn't solve it, but here's an idea I had after the contest ended:

        If we consider some m, then we want to find (m — n) numbers <= m where xor(1..m) = xor(the numbers we choose). Let k = xor(numbers we choose).

        We can get k like this: satisfy each bit from (msb, 0) in that order (msb is most significant bit). We can see that once we are done taking bits for some msb, we can jump down until the msb changes, and no matter what we choose we do not mess up the answer we already have.

        The problem with this is we need at least bitcount(k) moves to make it work. What if (m — n) is less than this? We can combine some bits and take them all at once. This is because we can find any number < 2^(msb) in [1..m]. Then we need at least min(bitcount(k), 2) moves to make it work.

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

    If $$$n$$$ is $$$4k + 3$$$, you're done. $$$\newline$$$ If $$$n$$$ is $$$4k$$$, $$$m = n + 1$$$. Remove 1. $$$\newline$$$ If $$$n$$$ is $$$4k + 2$$$, you can prove that unless $$$n + 2$$$ is of the form $$$2^k$$$, you can remove 2 numbers keeping $$$m = n + 2$$$. Otherwise, $$$m = n + 3$$$. $$$\newline$$$ Similarly, if $$$n$$$ is $$$4k + 1$$$, you can show that unless $$$n + 3$$$ is of the form $$$2^k$$$, you can remove 3 numbers keeping $$$m = n + 3$$$. Otherwise, $$$m = n + 4$$$.

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

In case anyone wants to upsolve the IP problem (not sure how strength of test data compares): https://codingcompetitions.withgoogle.com/kickstart/round/00000000004349ac/0000000000434880

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

Why 96 for problem IP?

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

Question for anyone from quora, or anyone with knowledge of last year's contest result:

Upto what rank can people expect to get interview call from quora?

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

How to solve "subtracting?"

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

    Congratulations on the only full solve for cake!

    There are a few ways to subtract better than random

    • From classes that are overrepresented (this was most effective in internal testing)
    • From points of the same class that are close to each other
    • From points that are giving the strongest and correct prediction if evaluated with the trained model

    This requires some intuition on how classifiers, metrics and the black magic of gradient boosting decision tree works.

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

    33 points: for each point, find the distance to the closest point of the same class. Keep $$$n-k$$$ points with the maximum value. (kind of "deduplicating" the points)

    52 points: the same, but when calculating the value for each point $$$i$$$, only consider points $$$j > i$$$ (this way, if two points are close to each other, we don't remove both because of that, but only remove one).

    100 points: first, pick around $$$0.5 \cdot (n-k)$$$ points using algorithm X, then pick the remaining $$$0.5 \cdot (n-k)$$$ points using the above method. (and do a lot of parameter tweaking)

    Algorithm X: for each class, try to pick a representative subset of points of size $$$0.5 \cdot (n-k) / num_{classes}$$$. Start with an arbitrary point, then repeat adding the point with the largest sum (or min) of distances to the already picked points of the class.

    What were your approaches to cake and coldstart? In particular, I saw you solved coldstart very quickly, but my approach required a lot of tweaking too, so I wonder if there's anything simple. (My approach was built around finding training data records with at least 3 or 4 pairs <person; upvoted> in common with the query, then taking some kind of an average.)

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

      Cake: I modified bicsi's half-plane set: https://codeforces.net/blog/entry/61710. It maintains all half-planes that determine the border of the cake.

      Unfortunately, the version linked in that post didn't seem to compile, so I ended up copying a working version from https://infoarena.ro/monitor?task=camera, and then modifying it to dynamically maintain the area.

      For each employee, the idea is to first try the orientation of the plane that results in fewer half-planes being removed from the set. If that results in the remaining cake having less than half the area, we can afford to try the other orientation (and the number of vertices in the cake will halve). The runtime is $$$O(N\log N)$$$.

      Unfortunately, I didn't understand the code well enough to implement this so I ended up just picking an arbitrary vertex of the convex hull and first trying the orientation that resulted in this vertex still being inside the cake, and then trying the other. Definitely hackable but okay in the average case.

      I also ran into some floating-point issues (I think the __float128 in the code below is necessary). It is probably possible to make this WA ...

      Cake Code

      Coldstart: All you needed to do was modify one of huikang's solutions to last year's Quora challenge. :)

      Coldstart Code

      Congrats on the win! For "subtracting" I spent the last 20 minutes or so just resubmitting my nondeterministic solution that usually earned zero points but did manage to increase my score by a few points more than once. I suppose I was rather lucky that this earned me any points at all ...

      I also found it interesting that 20 of my points on "subtracting" came from printing out 0...k-1 ...

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

How to solve C?

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

    Use FFT. $$$\newline$$$ $$$polyA(i) = 1$$$, if $$$s[i] = A$$$. Odd coefficients of $$$polyA * polyT$$$ give you the values where $$$A$$$ and $$$T$$$ match. Similarly compute this for $$$G$$$ and $$$C$$$, add and take max over the odd coefficients.

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

      I had neither Karatsuba nor FFT in my library, so I quickly implemented Karatsuba and it was too slow.

      Tried FFT, it was also too slow. I guess people have optimized implementations in their libs if it worked for them?

      The limit on N was 300000, annoyingly only slightly above a power of two, hampering both Karatsuba and FFT. Changed the base case in Karatsuba from 32 to 40, still too slow.

      Unrolled manually the 40-40-loop in the base case of Karatsuba, also taking into account that we need only the odd coefficients. And now it passed...

      Not sure how it worked for other people, but my impression about that problem was that there was not much algorithmic thinking (the idea to use fast polynomial multiplication should be rather obvious for those who know the technique), more using prewritten algorithms and/or low-level optimizations.

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

        I had to think about this problem a lot as I am not well versed with FFT or convolutions. But since I knew the definition of convolution, I was able to notice that property in the problem.

        I have no idea how to calculate a convolution fast so I used the AtCoder Library

        There was minimal implementation and the code ran pretty fast. I was only able to solve this "library" problem because of ACL. Overall it was more of algorithmic problem for me, so I liked it a lot.

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

Where can we find the full standing of the contest?

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

In the tree problem (dfs from node 1) then for each node check all ancestors ans[node] = min(ans[node] , ans[ancestor] + R[ancestor] + C[ancestor] * distance) What's wrong with this? I couldn't pass first subtask

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

For those who did not participate the contest and would like to follow the discussion, here is the problem statements (thanks to rfpermen for downloading these)

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

What was the solution for DNA?

I see a lot of people solved it, but I still can't figure out a linear solution

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

    It is a FFT problem.

    Let $$$polyA$$$ be a sequence of numbers $$$a_0, a_1, \dots, a_{n-1}$$$ where $$$a_i=1$$$ if the $$$i$$$th letter in the string is "A" and $$$a_i=0$$$ otherwise. Make similar sequences for $$$polyT$$$, $$$polyG$$$, and $$$polyC$$$.

    Now, take the convolution of $$$polyA$$$ and $$$polyT$$$ (this is where FFT comes in, because FFT calculates convolution very quickly). Let's say the convolution is the sequence $$$c_0, c_1, \dots, c_{2n-2}$$$. For any $$$1\leq i\leq n-1$$$, observe that $$$c_{2i-1}$$$ represents the number of A-T/T-A bonds that will occur when you fold the DNA string with $$$i$$$ bases on the left side of the fold.

    Now, take the convolution of $$$polyG$$$ and $$$polyC$$$, and let's say the convolution is the sequence $$$d_0, \dots, d_{2n-2}$$$. By similar reasoning, $$$d_{2i-1}$$$ represents the number of G-C/C-G bonds that will occur when you fold the DNA string with $$$i$$$ bases on the left side of the fold.

    Thus, the number of bonds that will occur when you fold the DNA string with $$$i$$$ bases on the left side of the fold is $$$c_{2i-1}+d_{2i-1}$$$, and from here it is very easy to find the $$$i$$$ which maximizes $$$c_{2i-1}+d_{2i-1}$$$ using a simple for loop. Since we only do two convolution operations on sequences of length $$$n$$$, the complexity is $$$O(n log n)$$$.

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

Not even able to solve the first problem, the challenge is ended, can u share ur code here. (i mean the IP BLOCKs}

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +46 Проголосовать: не нравится
    import ipaddress
    n = int(input())
    lol = []
    for i in range(n):
    	lol.append(ipaddress.ip_network(input()))				
    result = ipaddress.collapse_addresses(lol)
    for x in result:
    	print(x)
    
»
3 года назад, # |
  Проголосовать: нравится +35 Проголосовать: не нравится

Any place for upsolving?

Also, picture is a standard problem, right? Count axis-aligned rectangles formed by line segments. I'm pretty sure I saw it at least once in a contest.

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

Have people received invitations for interviews or similar?