SecondThread's blog

By SecondThread, history, 9 months ago, In English

Hacker Cup Round 3 begins in about 1 hour! To compete, you must have placed in the top 500 in Round 2 in the human track, or top 25 in the AI track.

  • Participants who place in the top 200 of Round 3 will have a special "Top-200" badge on their shirts.
  • The top 25 contestants in the human track will advance to the Final Round.

As a reminder, in the human track, no communication with others or AI usage is allowed during the contest. (Likewise, in the AI track, no human code authoring or human decision making is allowed)

I'll post an update later this week with information about the shirt-claiming process.

Good luck, have fun, and we'll see you on the scoreboard!

  • Vote: I like it
  • -23
  • Vote: I do not like it

»
9 months ago, hide # |
 
Vote: I like it +84 Vote: I do not like it

200 out of the 500 qualified participants seem to be cheaters. Depending on how gpt-proof the problems are, getting a top-200 t-shirt will either be very easy, or impossible for me.

  • »
    »
    9 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it -112 Vote: I do not like it

    Why do you say they seem to be cheaters?

    To be clear, I'm asking for specific evidence of specific people. I agree at large there are many more cheaters, but finding conclusively whether a specific person cheated or not by looking only at their code can be very dificult.

    • »
      »
      »
      9 months ago, hide # ^ |
      Rev. 2  
      Vote: I like it +8 Vote: I do not like it

      their solution most likely matches with the style used by any llm , but what detection method can be used for them is also very difficult to come up with

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +73 Vote: I do not like it

      I completely understand that noone in Meta has the time to deal with that, given that the people are most probably just volunteering to organize this (which we're thankful about), but it is absolutely obvious that there are > 150 cheaters in first 500; even a couple of the most blatant examples were posted in couple of blogs here on CodeForces.

      • »
        »
        »
        »
        9 months ago, hide # ^ |
         
        Vote: I like it +11 Vote: I do not like it

        I ran a script to scrape users who included their codeforces handle on the leaderboard and compared their cf rating to their position.

        There were Pupils who ended up in the top 100 solving every problem, while there were grandmasters who didn't even end up in top 500.

        I think platforms need to have the balls to make probability based assessments and move from only banning/removing for 100% probability cheaters to something like 99.9%.

        It is much more difficult to detect cheaters in chess for instance, but they use heuristics like move timing and outperforming their ranking to make the determination. It would actually be much easier to use heuristics to catch cheaters in competitive programming.

        Some Heuristic examples:

        Look at attempted problems solved and the variance between failed problems (i.e someone who fails ANY 1200 rated problem will NEVER solve a 2500 rated problem within a small timeframe)

        Solution times, higher ranked competitors don't just solve more problems, they consistently solve easier problems faster and with less bugs. Theres a very clear pattern as the difficulty of the problem increases so does the time to solve it.

        Code style. Not everybody uses the same template for everything, but it's very clear based on variable naming and choice of data structures if the same person wrote the solution.

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +97 Vote: I do not like it

      does the geographical distribution of qualified participants not seem laughably different from that of the top-500 of an arbitrary div-1+2 with relatively gpt-proof problems?

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +72 Vote: I do not like it

      Common sense

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +37 Vote: I do not like it

      Being from India, I shouldn’t say this, but more than 200 users are from India and Pakistan combined, and about 190 users are from India alone. Now, when I checked previous seasons of Hacker Cup, in Round 2 there were hardly 20–30 people from India. Given that the current level of problems can now be solved easily using AI, it’s almost certain that at least 100 of these 190 users are cheaters, and there are more from other countries as well. I checked some of these people’s Codeforces accounts — many of them are barely Pupil on Codeforces. So if out of 500 users around 150 are cheaters, then this is a huge breach.

      • »
        »
        »
        »
        9 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        The number of Indian participants is actually higher than that. Just a look at the leaderboard will reveal those who are participating under a different country name.

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +14 Vote: I do not like it

      because most of the indians present in top 500 are barely specialists. suddenly giving better performance than most cm,m,gm. coincidence right..!

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +11 Vote: I do not like it

      img

      How do you explain this $$$?$$$

»
9 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Please postpone this and remove cheaters, I want to go to Round3 after 4 years :_

»
9 months ago, hide # |
 
Vote: I like it +36 Vote: I do not like it

183 indians in top 500,the youngsters from my country sure seem to be genuises.

»
9 months ago, hide # |
 
Vote: I like it +46 Vote: I do not like it

The wrong solutions of B passed due to weak tc. I will miss the T-shirt this year as well.

»
9 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

I wonder what all changed for cheaters when LLMs became decent. There have always been public groups (Telegram channels, etc) where solutions were shared openly. It's not like LLMs can spit out vastly different solutions to the same problem.

So, is it that they can be prompted to make custom modifications, like using the participants template and naming style, etc? But, this only makes the process of saving your submission from plagiarism checkers convenient. Was plag-proofing always the main bottleneck that demotivated participants from cheating?

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +13 Vote: I do not like it

    I think no strong person was willing to share solutions to hard problems, while now LLMs can solve hard problems.

»
9 months ago, hide # |
 
Vote: I like it +19 Vote: I do not like it

"CheaterCup"

»
9 months ago, hide # |
Rev. 4  
Vote: I like it +7 Vote: I do not like it

U also did not do anything/not even talking abt R2-B problem till now . This is so bad SecondThread

»
9 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

wtf is A

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +32 Vote: I do not like it

    Yeah, why was this the hardest problem of the contest? :P

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      I found B and D much approachable than it , I assumed the problems to be in increasing order of difficulties , failed and messed up here :(

»
9 months ago, hide # |
Rev. 3  
Vote: I like it +15 Vote: I do not like it

Rajneesh Chaudhary is cheating at its peak. He isn’t even a Master on Codeforces, yet he’s beating legendary Grandmasters with the help of AI. Shame on you—what a loser. You’re destroying the hard work of many problem setters and ruining the rankings of genuine contestants who actually grind and earn their skills. You’re not a pro coder—you’re just a cheater.

His linkedin Id-->

https://www.linkedin.com/in/rajneesh-chaudhary-37632a1b7/

Look this matter seriously SecondThread

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    ban rajneesh chaudhary SecondThread

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Thanks, we'll look into it.

    We're taking all the reports seriously. We obviously need to be able to defend DQs, but we do DQ tons of people.

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +45 Vote: I do not like it

      what if I am ranked 200 having solved 0 problem , then will I get the top 200 Tshirt ?

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +11 Vote: I do not like it

      What is the use of removing cheaters now? Suppose you can remove now 200+ cheaters but at what cost? Now round 3 would have 300 participants only? in which top200 is super easy? If you could do it earlier, genuine people would have given a chance :_ I told you to postpone, now see people were beating LGMs with AI at initial phase of round.

»
9 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

$$$O(N^3)$$$ passed in B :skull:

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it

    Thread-maxxing, I suppose?

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +10 Vote: I do not like it

      Yes, but turns out 3 threads are enough since there are only 3 testcases where $$$N = 6000$$$. And even with 1 thread all 65 testcases took my code $$$2.5$$$ minutes.

      • »
        »
        »
        »
        9 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        where did you acquire your nasa military-grade supercomputer?

        • »
          »
          »
          »
          »
          9 months ago, hide # ^ |
          Rev. 2  
          Vote: I like it +10 Vote: I do not like it

          I don't think this counts for a supercomputer :D

          Spoiler

          For this problem this laptop was enough. For more computational-heavy programs I also have 2 virtual machines with 100 cpu each.

          • »
            »
            »
            »
            »
            »
            9 months ago, hide # ^ |
            Rev. 2  
            Vote: I like it 0 Vote: I do not like it

            Bros side-chicks are more attractive than my main chick...


            Spoiler
  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +20 Vote: I do not like it

    Do you have a link to the submission? We had several brute forces that all took over 10 minutes to run one max case on an M1 Macbook Pro

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      My N^3 timed out. Even I am interested to see how did any O(N^3) make it through.

      SecondThread — this should be rejudged if that was the case.

    • »
      »
      »
      9 months ago, hide # ^ |
      Rev. 2  
      Vote: I like it +20 Vote: I do not like it

      https://pastebin.com/z6gFRzTR

      Works in 75 seconds on my machine (with THR = 3 variable which stands for the number of threads).

      Even without multithreading (THR = 1) it works in 150 seconds on all 65 testcases (3 of which are max cases).

      • »
        »
        »
        »
        9 months ago, hide # ^ |
         
        Vote: I like it -23 Vote: I do not like it

        You are freaking right! :(

        I just implemented mine and it runs with MT, which is sad and kinda unfair.

        I am going to post a clarification request on this SecondThread.

»
9 months ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

Does anyone have a different solution to D than virtual tree + inclusion exclusion on the values at the end?

  • »
    »
    9 months ago, hide # ^ |
    Rev. 4  
    Vote: I like it +35 Vote: I do not like it

    I did brute force with dsu + dfs for 1 <= i <= 500 and bruteforce with lca for i > 500. $$$O(N\sqrt{N}) + \sum_{i=501}^{N} (\frac{N}{i})^2 log(N)$$$

  • »
    »
    9 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it +30 Vote: I do not like it

    Can do small to large merging + inclusion exclusion. For every node and value $$$x$$$, count the number of nodes in its subtree that are multiples of $$$x$$$ and their sum of depths. Do this only for those $$$x$$$ that have non zero values of these counts. While merging at a node, iterate over all the values of the smaller set, and we have the info needed to find sum of distance between pairs of the two sets having gcd to be a multiple of $$$y$$$ for all $$$y$$$. Since final set is of size $$$O(n \log n)$$$, time complexity is bounded by $$$O\bigl(n \log n \cdot \log(n \log n) \cdot \log(n \log n)\bigr)$$$ or $$$O\bigl(n \log n \cdot \log(n \log n)\bigr)$$$ with unordered map.

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +20 Vote: I do not like it

    inclusion-exclusion (i.e. mobius function or the like) is assumed.

    For the main part, I directly do small to large. You need to be able to add $$$(size[t]) * (totalsize[t] - size[t])$$$ for each $$$t$$$ from $$$1$$$ to $$$n$$$, and perform point update. This can be handled like segment tree beats historic sum. (For each entry, store when was it last modified. When you modify a value, process the backlog of this old time stamp to the current time). Complexity is $$$n ln n log n$$$ (log from sieve and from small to large).

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I did small-to-large merging of maps of {factor -> (count, depth_sum) of all multiples of factor} for each subtree. With this I get for each factor f the total sum of d(u,v) for all u,v multiples of f. Then I convert this to gcd by just subtracting away multiples of f rather than inclusion-exclusion.

»
9 months ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

can someone explain the solution to A? everyone's code seems to be insanely convoluted

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +23 Vote: I do not like it

    Solve $$$K \le 2$$$ first, and assume that $$$K \ge 3$$$. Assign components from row $$$1$$$ to $$$N$$$. If the current component has a cell in leftmost position of previous row, just fill from left to right. Otherwise, fill from right to left. The only problematic case left is $$$(i-1,i-1)$$$ and $$$(i,i)$$$ is assigned to the same component(say $$$A$$$) but $$$(i,i-1)$$$ isn't(say $$$B$$$). Since $$$A$$$ does not include $$$(i-1,1)$$$, for the leftmost $$$(i-1,j) \in A$$$, swapping the components of $$$(i-1,j)$$$ and $$$(i,i-1)$$$ solves the issue. Note that $$$(i,j) \in B$$$ by the way we constructed.

    Some whine: my submission got rejected because I just colored with component number mod 26 after assigning components..

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +20 Vote: I do not like it

    ($$$k = 1$$$ and $$$k = 2$$$ are separate obvious cases.)

    Fill from smallest to biggest rows. We maintain this invariant: when we get to the next row and placed $$$k$$$ of each components, either the prefix or the suffix is free.

    if prefix is free:

    just go from right to left.

    if suffix is free:

    just go from left to right. However, if the remaining tiles you need to put are exactly $$$k-1$$$, then you need to leave one free place for the next color, then fill everything else and two cells of the next row.

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +33 Vote: I do not like it

    The following works (miraculously!) without any special cases, even for K=2.

    For each component, start with the vertex with the smallest degree. Continue building the component by selecting a neighbor (of the current component) with the smallest degree, and in case of equal degrees: the furthest (!) from the diagonal.

    For me it was more intuitive to stick towards the diagonal but this heuristic fails sometimes ((14, 9), (21, 9), (22, 32), …).

    • »
      »
      »
      9 months ago, hide # ^ |
      Rev. 2  
      Vote: I like it +5 Vote: I do not like it
      val parts = mutableListOf<List<Int>>()
      while (alive.isNotEmpty()) {
      	val vInit = alive.minBy { nei[it].size }
      	val comp = mutableListOf(vInit)
      	remove(vInit)
      	while (comp.size < k) {
      		val candidates = comp.flatMap { nei[it] }.toSet().intersect(alive)
      		if (candidates.isEmpty()) break
      		val v = candidates.minBy { nei[it].size * n + it / n + it % n }
      		comp.add(v)
      		remove(v)
      	}
      	parts.add(comp)
      }
      
»
9 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

So many FSTs in B :<

I wonder if the "Top-200" badge rule will hold when all participants with 0 score (currently ranked 202) get a rank <= 200 :p

»
9 months ago, hide # |
 
Vote: I like it +97 Vote: I do not like it
  • B: I like this very much, thanks.
  • C: My FFT fit in time, I couldn't get the point of this problem. Also I was almost running out of time for fixing my code for invalid input... (For those who struggles, check if $$$|C_i| \gt 2000$$$.)
  • D: I felt this was too standard for its position.
»
9 months ago, hide # |
Rev. 2  
Vote: I like it +39 Vote: I do not like it

These are todays cheaters without doubt. Kindly review and remove them.

Rajneesh Chaudhary (Raj)
Soumen Kumar (punisher2919)
Anukrati Chaturvedi (anukraticodes)
Shivansh Rana (ShivanshCoding)
Shivam Singh
Ramharsh Dandekar (Ramharsh-aidev)
Saurabh Bansal (Saurabh52bnsl)
Shivam Aryan (ultraaryan10)
Bunty Dgeneration (Bhupendra Gehlot)
Tarandeep Singh Juneja (tsj2003)
Pratik Suryawanshi (Pratik2912)
Mrunal Tarwatkar
Lokendra Mundele
Tanishq Gupta
»
9 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

For anybody who is stressed about cheaters, it's okay, I have a nice calming song about competitive programming. Helps me solve and got me LGM.

Lyrics:
»
9 months ago, hide # |
 
Vote: I like it +72 Vote: I do not like it

Screencast

What a weird score distribution. Handling all the cases in A is insane, while D is literally harmonic sum + virtual tree with 0 thinking. I'm assuming there are people who could copy something from their lib and add 20 lines.

»
9 months ago, hide # |
Rev. 3  
Vote: I like it +29 Vote: I do not like it

Thanks for the round! Overall, I enjoyed the round more than the last few Round 3s. A few thoughts:

It seems like the authors had a pretty hard time anticipating the difficulty distribution--my personal difficulty ordering was B, D, C (with the FFT solution), A, E, C (with the bitset solution), though I'd consider swapping A/E. This looks at least roughly consistent with the scoreboard--it seems like B and D were clearly the two easiest problems, with the other three having solve counts around similar orders of magnitude.

The result of this was that a substantial determinant of finals qualification was realizing which problems actually matter--assuming A was one of the easier problems, if not the easiest problem, would cause a contestant to spend lots of time on a problem that ultimately turned out to be inconsequential. This also came up in Round 2--D turned out to be easily the hardest problem of the round, and B was arguably harder than C but was worth far fewer points. It might make sense to recruit a larger testing force, possibly drawing from strong Codeforces users who have conflicts on the day of the actual competition, to get a more accurate sense of the difficulty of the problems.

Specific thoughts on the problems:

A: Nice problem, though far too hard for its position (based on my personal experience and the scoreboard). If I was setting the round, I would have guaranteed $$$K \geq 3$$$: this contest is already pretty detail/implementation-heavy, and I don't think dealing with $$$K = 2$$$ was an interesting part of the problem.

B: Good problem, nice little DP.

C: I wasn't a huge fan of this problem. I know of two solutions: a boring FFT approach and a bitset approach that relies on a pretty nice observation. The problem is that especially in the MHC format, it seems close to impossible to reject FFT (especially on a setup that e.g. uses AWS to run all test cases in parallel) but accept the bitset solution without multithreading. In this case, it looks like it was possible to push the FFT solution through with basic multithreading (this was surprising to me given the constraints--maybe the test data is weak?). This was disappointing to me since it rewards e.g. making assumptions about the strength of the test data, having a stronger PC, spending time on setup optimization, etc.

D: Fine problem, though most of the individual steps felt fairly standard.

E: Nice problem--for a while it seemed like the solution would involve lots of messy casework, but the implementation turns out not to be that bad after you write the $$$n = 6$$$ brute force.


In case it's of interest, my progress through the round looked like:

  • Spent 20 minutes on A before moving on to B
  • Solved B in 12m
  • Looked at scoreboard and moved to D, solved in 24m
  • Saw C had a solve and spent 45m thinking about it, came up with the bitset solution after the first 30m or so but convinced myself it was unintended/would TLE
  • Switched to E and worked on it for the remainder of the contest; I got fairly close, but ended up making too many mistakes along the way to finish in time. (In retrospect, I was more reluctant than I should have been to use the brute force as a subroutine, even though I had already written it to confirm that a solution always exists.)

Not realizing that my solution to C was fast enough was fairly sad, though it's not obvious that implementing C and then solving A in the last 90m of the round would have been much easier than solving E in the last 75m.


My solution sketches:

A: The problem is trivial when K = 1. When K = 2, color the cells in a checkerboard pattern; the answer is bounded from below by the number of cells of the more common color, and we can achieve this bound e.g. by tiling each row with horizontal dominos.

Now assume K > 2. A general strategy is to move down the pyramid from top to bottom, alternating between left-to-right and right-to-left. When we move down from level $$$i$$$ to level $$$i+1$$$ on the right side, we don't need to do anything special as long as our current component has at least two cells remaining, but if we have only one cell remaining, coloring the rightmost cell on level $$$i+1$$$ won't be connected to our existing component on level $$$i$$$. If this happens, shift this component to the right by one cell, then fill in the gap when we're traversing right to left on the next level.

B: Let dp[i] be the minimum cost to satisfy the constraints on lightbulbs 1..i. To transition from dp[i] to dp[j], we need to include a string of consecutive bulbs that will satisfy all conditions from i+1 to j. Each condition requires our string to have at least some fixed length and to start before some fixed point. Using prefix sums, we can precompute the minimum cost of a string of a given length starting at or before a given point in the array, allowing us to do each transition in O(1) for a total complexity of O(n^2).

C: Imagine we're building our string iteratively. We start with $$$W_1$$$, then, for each $$$i \gt 1$$$, we need to add on a suffix of $$$W_{i}$$$ such that the prefix of $$$W_i$$$ occurring when you drop this suffix matches the same-length suffix of $$$W_{i-1}$$$. This condition gives us several possible suffix lengths we can add on in step $$$i$$$, and we need to determine which total lengths can be achieved by choosing one suffix length for each $$$i$$$.

The key insight is that the set of suffix lengths we can choose in step $$$i$$$ consists of an arithmetic progression plus at most $$$O(\log |W_i|)$$$ extra lengths. To prove this, suppose that the prefix lengths of $$$W_i$$$ that match suffixes of $$$W_{i-1}$$$ are $$$p_1, p_2, ..., p_k$$$ in descending order. Because these prefixes of $$$W_i$$$ match the corresponding suffixes of $$$W_{i-1}$$$, we can think of $$$p_j$$$ as the longest shared prefix/suffix in the prefix of $$$W_i$$$ with length $$$p_{j-1}.$$$

The insight here is that we can break the sequence $$$p$$$ into $$$O(\log |W_i|)$$$ contiguous subsequences, each of which is an arithmetic progression. The idea is that if $$$p_j \geq \frac{p_{j-1}}{2}$$$, then the period of the first $$$p_{j-1}$$$ characters of $$$W_i$$$ must be $$$p_{j-1} - p_j$$$. Moreover, this must also be the period of the first $$$p_j$$$ characters (this can be proven by contradiction using the fact that $$$p_j \geq p_{j-1} - p_j$$$), which implies $$$p_{j+1} - p_j = p_j - p_{j-1}.$$$ This is enough to show that if we split the sequence $$$p$$$ wherever $$$p_j \lt \frac{p_{j-1}}{2}$$$, each subarray is an arithmetic progression, so $$$p$$$ can be written as the concatenation of $$$O(\log |W_i|)$$$ arithmetic progressions. (Credit to Golovanov399 for catching an incorrect assertion that used to be in this section; any remaining errors in this explanation are my own.)

Now, maintain a bitset representing the values we can reach using the first $$$i$$$ words. To insert word $$$i+1$$$, we need to construct the values we can reach by using each of our arithmetic progressions.

Fix one of our arithmetic progressions and start by adding the first term of the progression. Then, if there are $$$k$$$ terms in our progression and the common difference is $$$d$$$, we need to consider adding each of $$$0, d, \cdots, (k-1) \cdot d$$$ to our length. This can be handled using a trick similar to one often used to optimize subset sum DP: consider adding any subset of $$$d, 2d, 4d, \cdots$$$ until you get to the largest $$$2^q d$$$ with $$$2^q \leq k-1$$$, then add an optional $$$(k-1)d$$$ to cover the remaining values. This takes another $$$O(\log_2 |W_{i+1}|)$$$ bitset operations per arithmetic progression.

This bounds our complexity as $$$O \left( n |W_i| + \frac{K}{64} \cdot n \log^2 |W_i| \right)$$$, though in a comment below, dorijanlendvaj proves a stronger bound that eliminates a log from the second term. Even with one log, this seems a little tight, though the other comments suggest that the tests are weak enough that this should pass comfortably.

D: Apply Mobius inversion so that we need the sum of distances over all pairs $$$(u, v)$$$ where $$$u$$$ and $$$v$$$ are multiples of $$$k$$$, for $$$k$$$ from $$$1$$$ to $$$n$$$. Let $$$v_1, v_2, \cdots, v_m$$$ be the vertices that are multiples of $$$k$$$. Then, the sum of the distances is

$$$ \sum_{i = 1}^m \sum_{j = i+1}^m dep_{v_i} + dep_{v_j} - 2 \cdot dep_{lca(v_i, v_j)} = (m-1) \sum_{i = 1}^m dep_{v_i} - 2 \sum_{i = 1}^m \sum_{j = i+1}^m dep_{lca(v_i, v_j)}.$$$

The former sum can be computed with a simple DFS, iterating over the factors of each vertex. The latter can be computed using small to large merging. For each vertex, we'll build a map from $$$k$$$ to the number of vertices in the subtree of $$$v$$$ that are multiples of $$$k$$$. When we merge two sets, we can count the number of pairs with LCA $$$v$$$ and update our sum accordingly.

The total number of elements in each of our base sets is $$$\frac{n}{1} + \frac{n}{2} + \cdots + \frac{n}{n} = O(n \log n)$$$. Implementing small-to-large merging using a map gives a complexity of $$$O(n \log^3 n )$$$, though with a good constant factor since we only keep one of any two terms with the same $$$k$$$ when we merge. Alternatively, we can omit the map, which makes the implementation slightly messier but gives an $$$O(n \log^2 n)$$$ complexity (thanks to arvindf232 for pointing this out).

E: We'll iteratively try to move two 0's to the left of the string. As we do so, we'll use the fact that using a brute force, we can permute any six consecutive elements arbitrarily using at most 11 operations. For simplicity, I'll assume that there are no pairs of 0's at the start of the string; if this isn't the case, just pair the 0's at the start of the string with each other. The algorithm is as follows:

  • While there are fewer than two 0's in the first four positions, perform an operation where we greedily try to assign all 0's to one group and all 1's to another.
    • We can prove that the first iteration of this is guaranteed to put at least two 0's in the first $$$n/2$$$ positions. Then, the second iteration is guaranteed to put at least two 0's in the first four positions.
  • If there are at least six positions remaining, use the brute force to move 0's to the first two positions. Otherwise, we can apply the brute force to the last six positions (noting $$$n \geq 3$$$) to achieve the desired configuration.

If there's one 0 left to place after this, we can move it to the first position in one operation.

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    as soon as $$$p_j\geq \frac{p_{j-1}}{2}$$$ for any $$$j$$$, the remainder of the sequence $$$p$$$ is an arithmetic progression

    No, for abacabacaba we have $$$p = (11, 7, 3, 1)$$$. You are right that if we don't divide by at least 2, then the next several elements are terms of an arithmetic progression. But after that, the process is pretty much independent, so $$$p$$$ is in fact a concatenation of at most $$$\log|s|$$$ arithmetic progressions.

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Regarding multithreading or not -- my solution (based on this idea) worked for about 4-5s on a test 2000 1000000 10000a 10000a ... (2000 times) and maybe 10-15s on the same test but where all strings were 1000000a. Figuring that 90 tests 4-5s each is too unreliable, I decided to run my solution in several threads, but turned out that the tests were generous enough, so even in one thread my solution worked under a minute.

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Thanks for the correction! I'll edit the comment above--I think the rest of the solution mostly stays the same.

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +10 Vote: I do not like it

    I'm pretty sure that the solution to C only has a single log; the fact that an arithmetic progression only stops when the next element is less than half of the current one means that it always ends with a number that is $$$\leq$$$ the step, which means that at the end the number was divided by a number that is $$$\geq$$$ the number of elements in the arithmetic progression. This means that the product of the number of elements in the arithmetic progression is $$$\leq |W_i|$$$, so the sum of their logs(which is the amount of bitset calls made) is $$$\leq \log |W_i|$$$.

  • »
    »
    9 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +10 Vote: I do not like it

    for problem D: small to large merging can be done in O(n log n) (and is recommended in general). It doesn't seem like you really need the flexibility of a map here (which is the only reason to need a O(n log^2 n) merging, aside from ease of coding outside of prewritten code.)

»
9 months ago, hide # |
 
Vote: I like it +29 Vote: I do not like it

This may be extremely unrealistic, but I really do hope onsite finals could happen.

I am still very sad that the exact year I am capable to get into finals is the (almost) exact year onsite finals got discontinued. Getting into finals feels a bit without substance now...

  • »
    »
    9 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    fwiw, I think the last onsite finals were in 2019, so it has been a while since the finals moved online (but I agree it'd be exciting to return to an onsite format).

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it +56 Vote: I do not like it

    Easy, just advance to AtCoder WTF (jk)

»
9 months ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Dear SecondThread, Please Design a proper Mail Eco-system to inform contestants about changes(date,time) & result.

After the Rank improvement of participants, they are not even aware that they have Qualified for the next Round. I have seen a lot of Posts about this on Twitter. Most of the participants faced this issue and uncertainly they missed their next Round. I Hope next year it will be Better

Thank You!

»
9 months ago, hide # |
 
Vote: I like it +27 Vote: I do not like it

I didn't participate in the round (even though I qualified), but when I went to check the standings today, I saw that I had gotten rank 198, enough for me to get a special T-shirt!

Jokes aside, literally everyone who qualified to round 3 is top 200, as there are only 197 participants with a positive score. What will be done about the T-shirts? I'm not sure if it is already specified somewhere that you need to have a positive score to get a T-shirt, but in case it isn't, the most reasonable thing to do, in my opinion, is to just give the special T-shirt to those 197.

  • »
    »
    9 months ago, hide # ^ |
     
    Vote: I like it -15 Vote: I do not like it

    but giving away 303 more would not even cost an extra grand for meta :) , why not give it to all 500s after plag checks !

    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +16 Vote: I do not like it

      Kind of defeats the whole purpose of "Top-200" Badge.

      • »
        »
        »
        »
        9 months ago, hide # ^ |
         
        Vote: I like it +11 Vote: I do not like it

        multiple participants can hold a particular rank tho:) , joking , they should be giving to ones who have a +ve score indeed (obv after plag checks)

»
9 months ago, hide # |
Rev. 3  
Vote: I like it +49 Vote: I do not like it

I wrote problem A. While waiting for the public editorial to be available, you can check my solution here (this is a copy of the original doc that I shared with other Meta folks as a problem submission)

»
9 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

Excuse me, I see that there were 197 persons have positive score

So all the zero — score would be placed at 198th

So are they counted in top 200 ?

»
9 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Is it true that the participants in the AI track confused it for a format where they can submit solutions generated by public LLMs? Curiously, out of 25 participants in round 3, 22 are from India, 1 is from Bangladesh, and 3 have unspecified country but are probably from India or BD.

»
9 months ago, hide # |
 
Vote: I like it -55 Vote: I do not like it

Is anyone still hoping to get a T-Shirt? Seems like we are being scammed this year too :(

»
9 months ago, hide # |
 
Vote: I like it +38 Vote: I do not like it

When we can expect T-shirt claim option ? and for remaining people in top 200... will they select based on Round 2 rankings ?

»
9 months ago, hide # |
 
Vote: I like it +43 Vote: I do not like it

Any update about the T-shirts?

»
9 months ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Not a good management this year.. funny thing is that my round 2 rank is still improving somehow lol, it became 3-4 ranks better.

»
9 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

what if someone who was just more than 500 ,say 505-520 , till beginning of round 3 and wasn't qualified for round 3 , now after plag checks they come<=500 , then ,just curious ??

»
9 months ago, hide # |
 
Vote: I like it +77 Vote: I do not like it

Any updates on T-Shirts?

»
8 months ago, hide # |
 
Vote: I like it +33 Vote: I do not like it

Now as the season has concluded , any updates on T-Shirts?

»
8 months ago, hide # |
Rev. 2  
Vote: I like it +37 Vote: I do not like it

SecondThread please write a post giving updates regarding the exact time when t-shirt claim starts...checking the site daily is annoying.

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it +10 Vote: I do not like it

    Will do. I'll also email everyone. But they're available now if you want to check btw.

    • »
      »
      »
      8 months ago, hide # ^ |
       
      Vote: I like it +3 Vote: I do not like it

      Some countries aren’t available on the list. Will they be updated later, or will delivery not be available to those countries?

»
8 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

Six hours nineteen minutes right ascension, fourteen degrees fifty-eight minutes declination... No sign of the shirts.

»
8 months ago, hide # |
 
Vote: I like it +19 Vote: I do not like it

when the tshirt can be redeemed, any update..!

»
8 months ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

SecondThread, And any update on the shirts ??

Please Design a proper Mail Eco-system to inform contestants about changes(date,time) & result.

»
8 months ago, hide # |
 
Vote: I like it +35 Vote: I do not like it

When is the t-shirt claiming process scheduled? It's been very late now.

»
8 months ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

Looks like they'll start the process once people have forgotten about the t-shirt, so that their shipping costs become lower since fewer people will notice -- especially because they don't send any email updates regarding the same..

Or..... they're just enjoying the holidays. So let's wait.. :)

»
8 months ago, hide # |
 
Vote: I like it +38 Vote: I do not like it

Just so you guys know, the t-shirts are now available to claim on the hackercup profile. The last date to order is January 31st.

»
8 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

Can we get a size chart for the T shirt?

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    If you look at the neck label in the front view, it looks like it says "canvas" in the same layout as the previous years' shirts, Most likely it's the same supplier/sizing as previous years (link) but it looks like you can email them if you need to be 100% sure

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

ATTENTION EVERYONE! TSHIRTS ARE AVAILABLE FOR ORDER UNTIL JAN 31!!! DO NOT MISS IT THIS TIME