installb's blog

By installb, history, 8 months ago, In English

2139A — Maple and Multiplication

Idea: installb Preparation: installb,2014CAIS01

Solution
Code (C++)
Rate this problem

2139B — Cake Collection

Idea: installb Preparation: installb

Solution
Code (C++)
Rate this problem

2138A — Cake Assignment

Idea: wjy666 Preparation: wjy666

Hint
Solution
Code (C++)
Rate this problem

2138B — Antiamuny Wants to Learn Swap

Idea: tarjen Preparation: installb,tarjen,2014CAIS01

Solution
Code (C++)
Rate this problem

2138C1 — Maple and Tree Beauty (Easy Version)

Idea: installb Preparation: installb,tarjen,2014CAIS01

Solution
Code (C++)
Rate this problem

2138C2 — Maple and Tree Beauty (Hard Version)

Idea: installb Preparation: installb,tarjen,2014CAIS01

Solution
Code (C++)
Rate this problem

2139D — Antiamuny and Slider Movement

Idea: tarjen,StarSilk Preparation: installb,tarjen,StarSilk

Solution
Code (C++)
Rate this problem

2139E1 — Determinant Construction (Easy Version)

Idea: wjy666 Preparation: wjy666

Solution 1
Solution 2
Rate this problem

2139E2 — Determinant Construction (Hard Version)

Idea: wjy666 Preparation: wjy666

Since $$$50$$$ is a very tight constraint, the author did not find a method to construct the DAG for G2 as in Solution 1 of G1. If you have a better solution, please leave a comment below.

Hint
Solution A
Solution B
Rate this problem

2139F — Ode to the Bridge Builder

Idea: installb Preparation: installb

Solution
Code (C++)
Rate this problem
  • Vote: I like it
  • +235
  • Vote: I do not like it

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

Auto comment: topic has been updated by installb (previous revision, new revision, compare).

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

.

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

The E2 construction seems to be related to last week's Project Euler problem: Euclid's Labour

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

An easier way to construct the matrix from the DAG in solution 1 of E1:

Let $$$A$$$ be the adjacency matrix, where $$$A_{i,j}=1$$$ if $$$i\rightarrow j$$$ exists and 0 otherwise. Then, $$$(I-A)^{-1}=I+A+A^2+\ldots$$$, so $$$(I-A)^{-1}[1][n]$$$ counts the number of directed paths from $$$1$$$ to $$$n$$$. By Cramer's rule, since $$$det(I-A)=1$$$ (it's triangular), we also have $$$(I-A)^{-1}[1][n]=adj(I-A)[1][n]=(-1)^{1+n}det(B)$$$ where $$$B$$$ is the $$$(n,1)$$$ minor of $$$I-A$$$, so it suffices to output $$$B$$$ and possibly flip a row.

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

E looks nice!

Managed to squeeze randomized solutions to E1 (337671518) and E2 (337675705), but after the contest (didn't participate).

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

one "ll"(long long) costed me problem b and c in the contest :)

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

Why was the problem statement changed in Div 2 Problem D, Antiamuny Wants to Learn Swap? Can someone please show me an example where swapping 2 apart more than once is more optimal than only swapping one apart, but swapping 2 apart once is the same number of steps as swapping only one apart.

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

WTH is this "Monotonic Stack" work O(N) ?!.. With O(1) "extra" space . . .

left greater (from 2138B)
»
8 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

For problem C1: I was on track, but I do not understand this jump.

Now the problem can be considered as a knapsack problem, where you have d items with weight c1, …, cd. We need to find out whether you can take several numbers from c that have sum equal to k. This can be solved in O(n^2).

I was thinking along the lines of having 2 currencies (k, n-k). Finding the maximum number of items I can buy either using currency 0 or currency 1.

Item costs would be c1, …, cd

Meaning: assigning all 1 or 0 to that current level of the tree → this will increase subsequence by 1.

I think this should be a well-known problem (since the editorial skipped this transition). It would be really helpful if someone provides more context or an article link.

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

Div1 C1/C2 can be solved in $$$\mathcal{O}(n*\log (n))$$$ by using formal power series of log function to compute the first $$$n+1$$$ terms of:

\begin{align*} \prod_{w=1}^{n} (x^{c_w} + 1) \end{align*}

Of course we need to do this under a NTT friendly modulo. Yes, I know this solution is “hackable” by choosing the input carefully so that the resulting numbers are divisible by the modulo, but I’m usually not interested in this (if we want, we could choose between multiple modulos randomly, use a few modulos, etc.).

Link to my submission: 337680547 (my implementation of exp/log generating functions is not the best and it has high constant).

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

Div2 E2/Div1 C2 can be solved by binary search on answer also. For any height, I am checking by greedily assigning zeros or ones from bottom to top.

https://mirror.codeforces.com/contest/2139/submission/337622955

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

    Looks like it was hacked, in general doing something like this probably should contradict the NP-completeness of knapsack.

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

In Div.1 C2 / Div.2 E2, I don't think $$$\sum_{i=1}^{\sqrt{n}} \log c_i = O(\sqrt{n})$$$ is trivial. Here is a proof.

Under $$$\sum_{i=1}^{\sqrt{n}} i\cdot c_i = n$$$, maximaze $$$\sum_{i=1}^{\sqrt{n}} \log c_i = \frac{1}{\ln{2}} (\sum_{i=1}^{\sqrt{n}} \ln{c_i})$$$. $$$c_i \in \mathbb{R}$$$.

If $$$f(c_i)=\sum_{i=1}^{\sqrt{n}} \ln{c_i} - \lambda (\sum_{i=1}^{\sqrt{n}} i\cdot c_i)$$$ and then when maximazing $$$\sum_{i=1}^{\sqrt{n}} \log c_i$$$, it should have:

$$$\frac{\partial f}{\partial c_i} = \frac{1}{c_i} - \lambda \cdot i = 0$$$

So,

$$$c_i \cdot i = \frac{1}{\lambda}$$$

So $c_i \cdot i$ is a constant.

Under $$$\sum_{i=1}^{\sqrt{n}} i \cdot c_i = n$$$, so $$$i\cdot c_i = \sqrt{n}$$$, so $$$c_i = \frac{\sqrt{n}}{i}$$$.

So $$$\max_{c_i} (\sum_{i=1}^{\sqrt{n}} \ln c_i) = \sum_{i=1}^{\sqrt{n}} \ln{\frac{\sqrt{n}}{i}} = \sum_{i=1}^{\sqrt{n}} \ln{\sqrt{n}} - \ln{i} \sim \sqrt{n} \ln{\sqrt{n}} - \int_{1}^{\sqrt{n}} \ln{i} di = O(\sqrt{n})$$$

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

    Note that your final tilde doesn't work on asymptotic differences and any arithmetic that uses them: if $$$f(n) \sim a(n)$$$ and $$$g(n) \sim a(n)$$$, it doesn't mean $$$f(n) - g(n) \sim a(n)$$$. Instead, Stirling's approximation says $$$\sum_{i=1}^k \log i = \log k! = k \log k - k \log e + O(\log k)$$$, so $$$\sum_{i=1}^{\sqrt n} \log \frac{\sqrt{n}}{i} = \sqrt{n} \log e + O(\log n)$$$.

    It only works out in this case because the next terms of the sum and integral are large enough and therefore similar enough. Consider the claim $$$\frac{n^2}{2} - \sum_{i=1}^n i \sim \frac{n^2}{2} - \int_{i=1}^n i \cdot \mathrm{d} i$$$: it'd simplify to $$$-\frac{n}{2} \sim \frac{1}{2}$$$, which is false.

    Formal math is full of traps.

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

      Thank you for pointing out the mistake.

      Maybe this approach is also correct now?:

      $$$\sum_{i=1}^{\sqrt{n}} (\ln\sqrt{n} - \ln i) \le \ln \sqrt{n} + \int_{1}^{\sqrt{n}} (\ln\sqrt{n} - \ln i) di = \sqrt{n} \ln \sqrt{n} - \int_{1}^{\sqrt{n}} \ln i di= O(\sqrt{n})$$$

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

        Well, the first equality isn't correct or incorrect, it's just unproved. What are your elementary steps?

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

forward solution for div2C which i (elegantly) thought of last minute: after any operation Chocola's x becomes either x / 2 or x / 2 + 2^k, because Vanilla will always have 2^(k + 1) — x, so go over x bits (LSB to MSB) and its first 1 is already the 2^k at the beginning, and every operation we divide x by 2, if x's current bit is 1 we add 2^k and at the end just get rid of extra zeros at right

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

In problem E2, I have a $$$\log_{1.378}n$$$ solution if four non-zero numbers in a column is allowed.

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

Though having a terrible contest, I still hope you can enjoy these problems. For me, div1E is one of my favorite ideas, and I may have spent a hundred hours thinking through various scenarios for this problem.

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

If there are some hints before the solution, it will become better.

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

Is it possible to solve Div1A or Div2C using Dynamic programming by dp[k][k]? where dp[i][j] denotes we have performed i of 1st operation and j of 2nd operation....in every step,I will try to do 1st operation and 2nd operation if it is possible! my submission:337636880

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

I used greedy and binary search on C2 and surprisingly it worked.I tried to prove but I couldn't. I don't know whether the solution is correct or the test cases are weak.

submission

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

During yesterday's contest I submitted Div2E1 with greedy (was sure it would fail) — 337614514 but it didn't and passed all TCs (I ended up submitting another solution for E1 hence it was skipped in main testing). Then I submitted exact same solution to Div2E2 — 337616400 which gave WA on TC13 instead of a TLE.

Since both problems only differ in time constraints, only explanation I found was weak pretest for Div2E1. But again after contest I submitted same code as I did in contest, it passed main tests as well — 337667320. Am I missing some point here or the tests for Div2E1 are actually weak?

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

337680242

A clean way to solve Div1A :)

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

    may you explain this please?

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

      At any time, if your current value is $$$C$$$, you either become

      $$$\frac{C}{2}\quad\text{or}\quad\frac{C}{2}+2^k$$$

      after applying the operation.

      Visualize it:

      $$$\texttt{01010000}\longrightarrow\texttt{00101000}$$$
      $$$\texttt{01010000}\longrightarrow\texttt{10101000}$$$

      Either this or this... you shift and then either add one at the $k$-th bit or not.

      So... you can see that no bit is disappearing after you add them (you can't use any operation after a $$$1$$$ reaches the $$$0$$$-th bit; both become odd). The first one you add becomes the lowest bit, the second one becomes the second-lowest bit, etc.

      If you want to build something like

      $$$\texttt{011010}$$$

      starting from

      $$$\texttt{100000}\longrightarrow\texttt{010000}\longrightarrow\texttt{101000}\longrightarrow\texttt{110100}\longrightarrow\texttt{011010}$$$

      So it's like you are just building it from the lowest bit.

      Since the one for the lowest bit already exists ($$$2^k$$$), you start from the bit right after; if it's on, you use operation 2, otherwise use operation 1.

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

      key pattern comes from observing the bits of x and y = 2^(k+1) — x, starting from LSB. If the bits of x and y are same, no operation was needed at this level. If they differ, operation must have occurred and person whose bit is 0 at this position was one who gave half of their cakes.

      You can check this: 337705903

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

Very good problems! I like them

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

I think the solution of problem 2138C1 have a mistake. "If the maximum answer d is not achievable, we can show that you can always achieve w−1. " In my opinion,it would be d-1 instead of w-1.

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

regarding the editorial of div1C2. machine word length is denoted by $$$w$$$ (w), not $$$\omega$$$ (omega).

also, i have a different algorithm for subset sum in $$$O(n \sqrt n)$$$ time for this problem, and i think it has a simpler explanation. say, you have a bunch of elements of total weight $$$n$$$. consider any weight that appears three times: $$$x, x, x$$$. what weights can we get with these elements? we can get $$$0$$$, $$$x$$$, $$$2x$$$, and $$$3x$$$. i claim that i can get the same weights with only two elements! i only need $$$x$$$ and $$$2x$$$. if i replace $$$x, x, x$$$ with $$$x, 2x$$$ in the multiset of items, nothing changes. let's do this replacement process repeatedly. for each weight from $$$1$$$ to $$$n$$$ i will store the number of elements of this weight, then go through weights in the increasing order, and while some weight $$$x$$$ appears at least three times, i take two of its appearances and replace them with $$$2x$$$. here is the code snippet:

for (int x : items) {
    cnt[x]++;
}
for (int i = 0; 2 * i <= n; i++) {
    cnt[2 * i] += (cnt[i] - 1) / 2;
    cnt[i] -= ((cnt[i] - 1) / 2) * 2;
}

i claim that at the end of this process we have at most $$$O(\sqrt n)$$$ items. why? we did not change the sum of weights of all items. it is still $$$n$$$. however, now each weight appears in the list of items at most twice. it is a classical exercise that if the sum of some positive integers is equal to $$$n$$$, then there are at most $$$\sqrt{2n}$$$ distinct values among them. as in our multiset the multiplicity of each element is not larger than $$$2$$$, it implies that we have at most $$$2 \sqrt{2n}$$$ items in our final list. after that, we can solve subset sum trivially which would give time complexity $$$O(n \sqrt n)$$$ or $$$O(n \sqrt n / w)$$$ if we use bitsets.

i don't remember where i learned about this algorithm, so please share the source if you have it :)

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

I seem to have discovered a new solution(337665794) for Div1 E2(2138E2 - Determinant Construction (Hard Version)). First, construct a $$$50×50$$$ matrix (with row and column indices from 0 to 49) as follows:

$$$ \begin{bmatrix} 1 & 0 & 0 & 0& 0& 0 & \cdots&0& 0& 0& 0 & 0& 0\\ 1 & 1 & 0 & 0& 0& 0 & \cdots&0& 0& 0& 0 & 0& 0\\ -1 & 1 & 1 & 0& 0& 0 & \cdots&0& 0& 0& 0 & 0& 0\\ 0 & 0 & 1 & 1 & 0& 0 & \cdots&0& 0& 0& 0 & 0& 0\\ 0 & 0 & -1 & 1 & 1& 0 & \cdots&0& 0& 0& 0 & 0& 0\\ 0 & 0 & 0& 0 & 1 & 1 & \cdots&0& 0& 0& 0 & 0& 0\\ 0 & 0 & 0& 0 & -1 & 1 & \ddots&0 & 0& 0& 0 & 0& 0\\ \vdots & \vdots & \vdots& \vdots & \vdots & \ddots & \ddots&\ddots & \vdots& \vdots& \vdots & \vdots& \vdots \\ 0 & 0 & 0& 0 & 0 & 0 &\ddots& 1 & 1& 0& 0 & 0& 0 \\ 0 & 0 & 0& 0 & 0 & 0 &\cdots& -1 & 1& 1& 0 & 0 & 0\\ 0 & 0 & 0& 0 & 0 & 0 &\cdots& 0 & 0& 1& 1 & 0 & 0\\ 0 & 0 & 0& 0 & 0 & 0 &\cdots& 0 & 0& -1& 1 & 1 & 0\\ 0 & 0 & 0& 0 & 0 & 0 &\cdots& 0 & 0& 0& 0 & 1 & 1 \end{bmatrix} $$$

Observing this matrix, we can see that all rows and columns with odd indices contain fewer than 3 non-zero elements. This means we can add non-zero elements to these odd-indexed rows or columns, with at most one addition per row or column. The initial determinant value of the matrix is 1. Considering adding non-zero elements in the upper-right region of the matrix, we find that if we modify the value at position $$$a_{ij}$$$ (where both $$$i$$$ and $$$j$$$ are odd, and $$$i \lt j$$$) to $$$k$$$, the determinant value increases by $$$k \times 2^{(j-i)/2 - 1}$$$, and modifications at different positions do not interfere with each other.

Thus, the original problem is transformed into representing $$$k-1$$$ as a sum of terms in the form $$$\pm 2^{k_1}, \pm 2^{k_2}, \dots, \pm 2^{k_t}$$$, where $$$k_1 \le k_2 \le \dots \le k_t$$$. The key point is that we can only find corresponding positions in the matrix for each exponent $$$k_i$$$ if adjacent exponents satisfy $$$k_i + 2 \le k_{i+1}$$$—if the exponents are too close together, it becomes difficult to satisfy the constraint of adding at most one non-zero element per row or column. I adopted the following method: check the binary representation of $$$k-1$$$ from the lowest to the highest bit. If the bit corresponding to $$$2^k$$$ is 1, then the term $$$\pm 2^k$$$ must be included. The strategy here is: if the bit corresponding to $$$2^{k+1}$$$ is also 1, we add $$$+2^k$$$; otherwise, we add $$$-2^k$$$. This way, once we add $$$\pm 2^k$$$, we won't add $$$\pm 2^{k+1}$$$ subsequently. Since the binary representation of k=1e7 has its highest three bits as "100..." in magnitude, the maximum term we need to add is only $$$\pm 2^{23}$$$, which matches requirements.

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

I used a bin-searching + greedy approach in both E1 and E2 div2, which got accepted. But now when I am trying to submit it again, it is getting WA on test 68. Who can disprove my solution?https://mirror.codeforces.com/contest/2139/submission/337639284

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

I 've solved E1 and E2 using binary search + greedy. Can anyone prove my solution? 337657306

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

installb typo in C1's editorial : w-1 => d-1

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

E1 question was very nice but in part E1 my solution passed on all test cases which uses a greedy approach after finding depths. But Greedy approach fails on the test case:

n=7,k=3 and parents followed by 1 2 2 3 4 4

Which confused me a lot during contest as the same solution failed on E2 because of missing test case in E1. I think there should be addition of such test case to E1 also as it lies within the constraints so that no one else faces the same problem.

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

Why is it always possible to achieve (min_depth_of_any_leaf) − 1 in E1?

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

?

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

For my fellow low rated participants if the following statement from C1's editorial isn't clear on why its true :

"As all leaves have the same depth, c_d should be the maximum element in the array, so you are always able to select a label for groups 1 to d−1"

think about this statement :

"if there are k sources which have varying levels of some thing and you need s units from one source -- as long as sum of number of units in all sources is >= k*s the source with maximum number of units will have >= s units of that thing to give !

this is because the average is established to be >= s and the maximum will always be >= average ! [pigeon hole principle]"

combined with the fact that the number of nodes in each level are non-decreasing so depths of all levels before the min depth of a leaf would have lesser than the average number of nodes per level we're concerned about -- you should now be able to reason why its true !

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

    Now the problem can be considered as a knapsack problem, where you have d items with weight c1,⋯,cd . We need to find out whether you can take several numbers from c that have a sum equal to k . This can be solved in O(n2) .

    Can you please explain how it got transformed to a knapsack problem?

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

I am new to the concept of bitsets.

Could someone explain the bitsets solution for C2? Like how to go about doing it?

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

has Rating get updated for this contest 1048 div 2? because mine is still not updated yet

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

Problem C is an excellent problem, but I don't see the point of C2. Is it just to test bitset optimization? The $$$O(n\sqrt{n})$$$ multiple knapsack solution is so ingenious—why not make it a separate hard version instead?

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

How to prove the solution of 1A reach the minimum?

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

Now the problem can be considered as a knapsack problem, where you have d items with weight c1,⋯,cd . We need to find out whether you can take several numbers from c that have a sum equal to k . This can be solved in O(n2) .

Can someone explain how it got transformed to a knapsack problem?

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

I think D1C is one of the coolest problems I've done! Here's a short editorial:

(By the way, since the answer is obviously bounded by the minimum depth of any leaf, just assume we've already truncated the tree by discarding all nodes with depth > min_depth from here on out. This also means that instead of having to use exactly $$$k$$$ zeros, we can use anywhere between $$$\max(sz - (n - k), 0)$$$ and $$$\min(sz, k)$$$ zeros, where $$$sz$$$ is the number of nodes that still remain in the tree after truncation.)

Off the bat, note that we're allowed a ton of freedom with how we fill values into the tree---the only constraint is the total number of 0s/1s, which gives us a huge number of possible configurations to work with. My friend andrewgopher would refer to such a problem as continuous.

This should make us suspect that we can never stray too far from a best-case coloring, in which every layer of the tree is either entirely $$$0$$$ or $$$1$$$. And this suspicion turns out to be correct, as we can show that we can always color nodes such that at most one layer contains both 0s and 1s. One simple way to do this is to run a BFS from the root until we hit $$$k$$$ nodes, color those $$$0$$$, and color all remaining nodes with $$$1$$$.

Therefore, we can always color the tree in a way such that at most $$$1$$$ layer has a mix of $$$0$$$s and $$$1$$$s. This is actually really nice because if, hypothetically, there were $$$2$$$ mixed layers, the LCS length could be either $$$d - 2$$$ or $$$d - 1$$$, where $$$d$$$ is the depth of the tree. But, if there is one mixed layer, we know that the LCS length must be $$$d - 1$$$, and if there's no mixed layers the LCS is obviously $$$d$$$. This greatly reduces the complexity of the problem.

Thus, the question then becomes whether we can achieve a coloring with no mixed layers---this can be done with a simple knapsack. Here's my submission: 337692707

And that's it! The only thing I disliked about this problem isn't even an issue with the problem itself: rather, it's the fact that going from C1 to C2 is just "do you know bitset?"

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

for DIV2D/DIV1A, if nxt[i] is the index of the next element that is less than a[i], can I assert that the result of [l, r] is NO only if nxt[nxt[l]] <= r ?

For me it sounds logic, and currenlty having wa2, can someone explain what I am missing?

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

I had a diffrent way of solving Cake Assignment here

Do check it out

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

Can anyone please tell me whats wrong with my solution to DIV2 D if possible? https://mirror.codeforces.com/problemset/submission/2138/340803037

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

I think this solution: 355700213 for problem 2138C1 - Maple and Tree Beauty (Easy Version) can be hacked. It only checks for sum k (or n — k) and ignores other valid distributions.

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

how are test cases of E1 so weak, my solution got accepted for E1 ,but got wrong ans on test 3 for E2

»
7 weeks ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Im late but i got an easy wave to prove the answer of C1/C2 is at least d — 1 (where d is min depth of all leaves). Assume there are at 2 group $$$i_1$$$ and $$$i_2$$$ that have size $$$c_1$$$ and $$$c_2$$$. WLOG, assume $$$c_1 \lt = c_2$$$, using Pigeonhole Principle, we know that there is at least $$$\lceil \frac{c_1 + c_2}{2} \rceil$$$ $$$0's$$$ or $$$1's$$$ in both group. We have: $$$\lceil \frac{c_1 + c_2}{2} \rceil \gt = \lceil \frac{2c_1}{2} \rceil = c_1$$$, which mean we can fill $$$i_1$$$ with $$$0's$$$ or $$$1's$$$. Apply this over and over again we can reduce mixed group to one or zero