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

Автор ahsoltan, история, 14 месяцев назад, По-английски

2122A - Greedy Grid

Solution
Bonus

2122B - Pile Shuffling

Solution
Bonus

2122C - Manhattan Pairs

Solution

2122D - Traffic Lights

Solution
Bonus

2122E - Greedy Grid Counting

Solution
Bonus

2122F - Colorful Polygon

Solution
Bonus

2122G - Tree Parking

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

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

Thanks for the editorial. B gave me cancer.

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

Does this paper essentially solve F?

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

thanks for quick editorial.. although I got cooked in this round by problem C

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

Thanks for the fast editorial :)

D is a good problem but it's too hard for a div.2 D.

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

After solving G, I felt that it would be easier to use OEIS for the whole problem... I don't think it's good.

The induction part (or "OEIS part") in the editorial can also be replaced with a simple bijection: Consider the DFS order, visiting the larger child earlier. Then a leaf corresponds to a descent.

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

    Yeah, I heavily dislike the fact that the main difficulty point of this problem can be resolved by simple OEIS search. But this was also educational in the sense that I should try to think less and brute force more when I see a counting problem.

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

In problem B, why can't it be

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

How does the checker for F work?

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

Hilarious but I actually came up with problem D 3 years ago, proving that answer is $$$\leq 2n-3$$$, but during the contest I completely forgot about this, submitting some bullshit. Here is my original proof writeup translated from Ukrainian.

We can restate problem as follows: there is an initial message in node $$$1$$$; once node $$$v$$$ gets a message, it starts transmitting it to its neighbors in arbitrary order. What's the smallest time until the message reaches node $$$n$$$?

Answer: $$$2n-3$$$

Solution. Consider a path on $$$n$$$ vertices in which vertex $$$i$$$ is connected only to $$$i-1$$$ and $$$i+1$$$.
Let each vertex $$$i$$$ ($$$2\le i\le n-1$$$) first send a message to vertex $$$i-1$$$ and then to $$$i+1$$$ (if it exists).
Clearly, vertex $$$n$$$ receives the message at the end of second $$$2n-3$$$.

Now we prove that every vertex is reached within $$$2n-3$$$ seconds.

Let $$$S_i$$$ be the set of reached vertices after second $$$i$$$.
A vertex $$$v\in S_i$$$ is called alive if it has at least one edge leaving $$$S_i$$$.
For every $$$v\in S_i$$$ define $$$d_{v,i}$$$ to be the number of neighbours of $$$v$$$ that lie in $$$S_i$$$ and to which $$$v$$$ has not yet sent a message.

We maintain integers $$$\bigl[\ell_i,\dots,r_i\bigr]$$$ such that the multiset $$$( d_{v,i} | v\in S_i )$$$ is majorized by the sequence $$$\bigl[\ell_i,\ell_i+1,\dots,r_i\bigr]$$$.
Initially $$$\ell_0=r_0=0$$$. Let's update them as we transition to the next second.

Case 1. No new vertices are reached in second $$$i+1$$$. Every alive $$$v\in S_i$$$ uses one of its edges inside $$$S_i$$$, so $$$d_{v,i+1}=d_{v,i}-1.$$$ Hence the multiset is now majorized by $$$\bigl[\max(0,\ell_i-1),\,\dots,\,r_i-2,\,r_i-1\bigr]$$$

Case 2. $$$k\ge 1$$$ new vertices get message in second $$$i+1$$$. For a new vertex $$$v$$$, $$$d_{v,i+1}\le (r_i-\ell_i+1)+(k-1)$$$, while for an old $$$v\in S_i$$$, $$$d_{v,i+1}\le d_{v,i}+(k-1)$$$. Thus the new degree multiset of alive vertices in $$$S_{i+1}$$$ is majorized by $$$\bigl[\ell_i+k-1,\,\dots,\,r_i+k-1,\, (r_i-\ell_i+1)+(k-1),\,\dots,\,(r_i-\ell_i+1)+(k-1)\bigr]$$$ which itself is majorized by $$$\bigl[\ell_i+k-1,\;\ell_i+k,\;\dots,\;r_i+2k-1\bigr]$$$

Consequently, if $$$k_i$$$ vertices are added in second $$$i$$$ (either $$$k_i=0$$$ or $$$k_i\ge1$$$), the choices $$$\ell_{i+1}=\ell_i+k_i-1, r_{i+1}=r_i+2k_i-1$$$ preserve the majorization property.

Suppose not all vertices are reached after $$$2n-3$$$ seconds; then some vertices remain alive.
However, $$$r_{2n-3}=r_0+\sum_{i=1}^{2n-3}(2k_i-1)=0+2(n-2)-(2n-3) = -1$$$ which is impossible. Hence every vertex is reached within $$$2n-3$$$ seconds.

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

Thanks for this btw when will be rating changes waiting...

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

I was curious to know that what is Problem Locked verdict on someone's submission. How's that achieved? If someone could share..

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

can somebody please explain problem B?

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

    The tutorial is well explained but I'll try to explain it clearly. You only have to count how many elements you have to remove, because you can put each element you remove in its final position. So, iterating though each pile, if in one pile you have more 1s than target, you have to remove all the 0s and the exceeded 1s, add that to the result. If not, check the 0s, if you have more 0s than target, add the difference between initial 0s and target 0s. I hope it's more clear now.

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

Wow, this contest made my brain TLE for sure

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

why complexity for B O(N^3)>>???

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

I solved D at 0:21 (and even got an intermediate result of global top-2!). It is hilarious that I spent literally less then a minute thinking about bounds and told myself: we can solve in $$$10\,000$$$ steps because after each step we wait no more than $$$deg(v)$$$ and we know $$$\sum deg(v) = m$$$ and we know $$$n\sim m \sim 5000$$$, right?

I feel I got really lucky. In retrospective it seems really not obvious why 10k is enough. Definitely kind of "I believe this should work" problem, idk if this is good for Div2D.

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

B was just too unintuitive for me—I couldn't figure it out.

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

Can anyone give me a testcase why this code 329867964 for d fails?

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

50 mins to solve B by analyzing. 20 mins to solve D by guessing.

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

Can anyone explain me the solution of C in simple way?? The editorial went over my head :(

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

Can anyone tell in B, if b>d why we do a+(b-d).. a is number of zeros but isn't it optimal to first give maximum zeros to other number possible that is reduce a to c(final state) and then do c+(b-d)?

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

Is D too difficult for a D? The upper bound analysis of this problem makes me think it has the difficulty level of F.

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

    its rating is 2300, definitely not F

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

    Problem difficulty isn't based on how hard it's to prove, it's based on how hard it's to stumble upon the solution. In this case, guessing that it works is easier than proving, so that's taken as the difficulty.

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

    For some reasons some contests are ordered by guess difficulty rather than by difficulty to actually solve (I guess it would be worse if such a guessable problem was at F, but it's not really that much better at D).

    It would be better to use such problems on math contests rather than programming contests, but as it is I guess the meta on Codeforces really is just to guess...

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

      In a math contest, it'd most likely be about finding a tight bound, which fundamentally changes how a proof can be approached. In a programming contest, it's very very common to make something that resembles a proof but isn't one because the objective is different — you don't need to know if the bound on time is $$$10N$$$ or $$$2N$$$, only that it should be low enough that your suboptimal code will fit into time and memory limits. You can start by writing a code and analysing it instead. You can generate many smaller graphs. Actual runtime is affected by cache efficiency here so maybe you need to optimise that, depending on your implementation — the time limit is kinda tight. You need to fit into memory. After experimenting a bit, getting rough insight into the problem, maybe you'd come up with a proof much easier.

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

        proving the answer is O(n) also makes for a decent math problem (but easier). A lot, and I mean a lot of people did not even have any idea why the answer is O(n), or had a fake proof for their solution. You are one of the few exceptions.

        I did not even read constraints on $$$M$$$ and just assumed it would be small too.

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

    Please, calm down bro. You can't denigrate a problem only because you have not come up with its solution quickly during contest or lost rating.

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

thx for the editorial, C teach me some new things.

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

D was cool but I'm sad my python didn't go through even though the complexity seems ok-ish, why limits are not more lenient here?

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

wtf is B bonus ?

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

in problem C this was my approach

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

Loved the problems, B was too much fun!

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

lmao for problem d i just guessed something like: in the best way every "relax" operation that maybe make the first answer bigger (but can make the second answer smaller) will be done at most 20 times for every vertex. so anyone can hack? plzplz

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

What a great set of questions! The difficulty level is just right, covering a wide range of knowledge points. Moreover, the questions are based on practical scenarios, and the solutions are quite natural. A big thumbs up to the question setter!

题出的好!难度适中,覆盖知识点广,题目又着切合实际的背景,解法比较自然。给出题人点赞!

ps:This is irony.

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

This was a great round , B was nice , C was on an idea that i saw for the first time so got to learn something new from C itself . Looking forward for more rounds by Order Capital.

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

i think D is too hard that due i got a lot of "Wrong Answer On Pretest 2" :(

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

In problem A for m = n = 2 why cant we have a grid like

1 900
2 3

max greedy path has sum = 1 + 2 + 3 while max path is 1 + 900 + 3

therefore the answer should be "YES"

Someone tell me where I am wrong ?

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

Holy moly, div 1~2 is different from div 2., with just solving 3 question I got +delta

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

Is there a solution for C, where the 2d coordinates are transformed into 1d form, and then the smallest and biggest are paired? (my thought process throughout the contest was to transform the coordinates somehow. But the transformations resulted in scaling the manhattan distance)

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

Here is my solution for problem D which passed system tests, but I was unable to prove it. I hope either someone will hack it or provide the proof: Let's first try to minimize total time. I just have state (i, x) for being in vertex i and trying to go on x-th edge outgoing from i. After this my assumption was that in optimal solution (considering minimizing waiting time) you never need to arrive more than n minutes late compared to earliest arrival time in any vertex. But as I said above, I was unable to prove it. Any counterexamples or insights will be appreciated.

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

    I wrote this exact same solution. I thought I proved it during the contest, but after the contest I realized my proof was wrong. I asked many 2600+s and none of them proved it. Maybe the answer is really small(<=2n-3) so there is no counter ex for the +n bound.

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

    Hey can you tell me what you did in your code. We can prove that all vertices are reachable in maximum $$$2n - 3$$$ seconds. I understood that part, but I am unable to understand your implementation.

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

      firstly, I calculated earliest arrival time for each vertex. Then, as mentioned above, I assumed that you don't need to arrive more than n minutes later than earliest arrival time for each vertex. Now graph states become (v, t) where v is the vertex you are currently and t is time passed relative to earliest arrival for this vertex. We need to calculate minimum waiting time. We have transitions from (v,t) to (v, t+1) with cost 1, and transition to (to, current_time — D[to] + 1) with cost 0, where to is vertex where we can go and D[to] is earliest possible arrival in this vertex.As costs are 0/1 we can use 0/1BFS

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

How to solve Problem C if the goal is to minimize the sum of Manhattan distances? Any ideas or approaches?

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

does same solution work for $$$C$$$ in 3D case?

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

In B,I wrote an O(n) solution in the contest.

submission

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

would it be possible to solve problem D with some kind of dijkstra approach?

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

https://codeforces.me/contest/2122/submission/329995334

Can someone help me with this.Its TLE on 9th test even though as per me i have a O(N) soln.

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

    your solution is O(N) — not sure what is causing the TLE. Try to use '\n' instead of endl as it speeds up the output (endl is flushing the output buffer which is not a fast operation whearas with '\n' the buffer only flush when it's full or when the program terminates)

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

    You are missing two critical lines

    std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr);

    never forget this in your C++ code

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

-

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

How to finish E in O(nk)?

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

For E,how to do it in O(nk)?

I can only come up with a solution in O(nklogk) though using convolution in state transition

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

    Why convolution? The state transitions are just ("add anything between 1 and $$$K$$$" or "add fixed number") and ("subtract anything between 1 and $$$K$$$" or "subtract fixed number"). Prefix sums should be enough.

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

      I'm so sorry,but I still don't know how to do in O(nk) though prefix sums.

      I read your code(329839824) and my code(330058406).Such as your code,the dp[i+1][j_nxt] = (dp[i+1][j_nxt] + dp[i][j] * cnt_dif[dif + (K-1)]) % MOD;//j_nxt=j+difseems like only using convolution. Could you help me? I sincerely thank you. Please forgive my worried English.

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

        There's no point in reading my code, I didn't overoptimise for that bonus.

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

          Thank you all the same!I know that the cnt_dif is special so that we can cauculate the result in O(nk)

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

            Our English teacher will cry after she sees your broken English.

            Dear autumoon , I'm sorry .

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

            Through further reflection, I discovered that for an $$$f(z) \times g(z)$$$, if each coefficient of $$$g(z)$$$ can be expressed by a $$$k$$$-degree polynomial, then it can be computed in $$$O(nk^2)$$$ time.

            Specifically, consider the target exponent $$$s = i + j$$$. By replacing each indeterminate in the polynomial expressing $$$g(z)$$$'s coefficients with $$$s$$$, we obtain a coefficient polynomial for each power term. This polynomial should treat $$$s$$$ as the variable, with coefficients derived from the original polynomial. Ultimately, this can be transformed by incorporating the exponent into $$$f(z)$$$ and computing the result via prefix sums. The coefficients of each prefix sum are then determined based on the exponent of each term in the resulting polynomial.

            For example, given $$$f(z) \times g(z) = h(z)$$$ where $$$g(z) = \sum (b + k i) z^i$$$, we have:

            $$$ \begin{aligned} [z^n]h(z)&=\sum_{i=0}^n f_ig_{n-i}\\ &=\sum_{i=0}^nf_i(b+kn-ki)\\ &=\sum_{i=0}^n-k(i\times f_i)+(b+kn)\sum_{i=0}^nf_i \end{aligned} $$$

            This can be computed by maintaining the prefix sums of $$$i \times f_i$$$ and $$$f_i$$$.

            When $$$g_x$$$ is a linear function, this approach applies. Higher-degree cases can be handled similarly.

            The translation was finished by Deepseek because my English is too terrible.

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

ahsoltan can you please add the implementations

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

Here is the solution to G-Bonus (solution using purely generating functions).

if we let $$$T_{n,l}$$$ represent the number of valid permutations on all labelled trees with $$$n$$$ vertices and $$$"l$$$ leaves, and let

$$$t(x,y) = \sum_{n=0}^{\infty} \sum_{l=0}^{\infty} \frac{1}{(2n)!(n)!} T_{n,l} \ x^n y^l$$$

then we have the following recurrence relation

$$$T_{n,l} = \displaystyle\sum_{\substack{\forall \ (n_1,\cdots,n_r) \\ n_1 + n_2 + \cdots + n_r = \mathbf{n-1} \\ n_1 \leq n_2 \leq \cdots \leq n_r}} C(n_1,\cdots n_r) \cdot \frac{(2(n_1 + \cdots + n_r) + 1)!}{(2 \ n_1)!\cdots (2 \ n_r)!} \sum_{\substack{l_1 + \cdots + l_r = l \\ l_1 \leq n_1, \cdots , l_r \leq n_r}} T_{n_1,l_1} \cdots T_{n_r, l_r}$$$

where $C \left( n_1, \cdots , n_r \right)$ is the function that counts the number of partitions of $$${ 1,\cdots,n_1+\cdots+n_r+1 }$$$ into sets of sizes $$$1,n_1,n_2,...,n_r$$$ respectively (For example $$$C(2,1) = \frac{4!}{2!1!} = 12$$$ and $$$C(2,2) = \frac{5!}{2!2!2!} = 15$$$). In terms of generating functions, this becomes

$$$t(x,y) = \frac{1}{2} \int{e^{t(r,s) - \frac{1}{2} r(1-s)} dr}$$$

Taking partial derivative w.r.t $x$, we get

$$$\frac{\partial(e^{-t(x,y)})}{\partial x} = \frac{1}{2} e^{-\frac{1}{2}x(1-y)}$$$

Integrating w.r.t $$$x$$$, we get

$$$t(x,y) = -\ln\left( c(y) - \frac{e^{-\frac{1}{2}x(1-y)}}{1-y} \right)$$$

Comparing coefficients of $x^0 y^m$ on both sides for all $$$m \geq 0$$$, we have that $$$c(y) = \frac{y}{1-y}$$$. Thus for $$$n \geq 1$$$, we have that

$$$[x^n \cdot y^l]t(x,y) = [x^n \cdot y^l] \{ -ln\left(1 - \frac{e^{-\frac{1}{2}x(1-y)}}{y}\right) \} = [x^n \cdot y^l] \{\sum_{m=1}^{\infty} \frac{1}{m} \frac{e^{-\frac{m}{2}x(1-y)}}{y^m}\}$$$

Expanding this further, we get

$$$[x^n\cdot y^l] \{ \sum_{m=0}^{\infty} \sum_{r=0}^{\infty} \frac{1}{m} \frac{(-1)^rm^r}{2^r\cdot r!} x^r (1-y)^r \frac{1}{y^m} \}$$$

We must have $r=n$ and $$$r-m=l$$$ to get the required coefficient. Substituting this we get

$$$\sum_{m=0}^{\infty} m^{n-1} \frac{(-1)^n}{2^n\ n!} \binom{n}{m+l} (-1)^{m+l} = \frac{(-1)^{n+l}}{2^n \ n!} \sum_{m=0}^{\infty} (-1)^m m^{n-1} \binom{n}{m+l}$$$

Taking $$$k = n-m-l$$$, we can re-write the summation as follows

$$$\frac{(-1)^{n+l}}{2^n \ n!} \sum_{k=0}^{n-l} (-1)^{n-l-k} {n-l-k}^{n-1} \binom{n}{k} = \frac{1}{2^n \ n!} A(n-1,n-l-1) = \frac{1}{2^n \ n!} A(n-1, l-1)$$$

Now, since the coefficient in $$$t(x,y)$$$ is equal to $$$\frac{T_{n,l}}{(2n)! \ (n)!}$$$, we have that

$$$T_{n,l} = \frac{(2n)!}{2^n} A(n-1,l-1)$$$

Now, since the root is fixed, we must divide by $n$ to get only labelled trees having $$$1$$$ as the root.

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

Problem B is annoying.
These are my solutions:
1. Without I/O optimization which got TLE on test 9: https://codeforces.me/contest/2122/submission/330519530
2. With I/O optimization it got succeeded. Link: https://codeforces.me/contest/2122/submission/330520090
Is this kind of behavior expected for problems or is it just too strict test cases?
This means that we always need to have the I/O improvements!

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

Can anybody help me with my solution in problem D.

I dont know why it is failing on test case 2.

Problem Link: https://codeforces.me/contest/2122/submission/331618437

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

for the question C can we come up with some solution which first involves pairing the coordinates which have diagonally opposite quadrants, since for them the manhattan distance will just be the absolute sum of each coordinate, so pairing 1st and 3rd quad , 2nd and 4th, but I am not sure about the leftovers after this is done, atmax there will be coordinates left in the 2 quadrants.

Also can someone explain the tutorial of C in a better way

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

I think problem C is well-designed.. seldom see such clear and beautiful solution, even compared with problems with complex data structures