Infoleague Winter 2022 Round 1 Div. 2 Editorial

Revision en9, by Gheal, 2022-01-08 17:00:59

103503A — Make Sum Great Again

Author: Gheal

Hint 1
Hint 2
Hint 3
Hint 4
Solution

103503B — Binary Search Search

Author: Gheal

Hint 1
Hint 2
Solution

103503C — Plates

Author: Gheal

Hint 1
Hint 2

Solution> Let <code>dp[mask]</code> be the minimum number of moves required to cover the first $$$\Sigma_{i=1}^k getBit(mask,i)*p_i$$$ slots with all plates of colours $$$c_1,c_2,\ldots$$$ where $$$getBit(mask,c_i)=1, \forall i$$$. Naturally, $$$dp[0]=0$$$.</p><p>Transitioning from $$$dp[mask]$$$ to $$$dp[mask+2^k]$$$, where $$$getBit(mask,k)=0$$$ can be done fairly easily. Let $$$pos=\Sigma_{i=1}^k getBit(mask,i)*p_i$$$ and $$$cntdiff(l,r,k)$$$ be the number of plates in the initial configuration $$$a_i$$$ which satisfy the following requirements: \begin{enumerate} \item $$$l \le i \le r$$$; \item $$$a_i \neq 0$$$; \item $$$a_i \neq k$$$. \end{enumerate}. From these definitions, the value of $$$dp[mask+2^k]$$$ can be computed using the following formula:</p> <center>$$$dp[mask+2^k]=dp[mask]+cntdiff(pos+1,pos+p_k,k)$$$</center><p>$$$cntdiff(l,r,k)$$$ can be calculated in $$$O(1)$$$ per query using prefix sums. Calculating the prefix sums has a time complexity of $$$O(n \cdot k)$$$. </p><p>Intended time complexity: $$$O(n\cdot k + 2^k \cdot k)$$$</p><p>Reconstructing the final configuration will also require an auxiliary array $$$prev[mask]$$$ — the last colour added to $$$mask$$$. </spoiler></p>

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en20 English Gheal 2022-01-08 21:32:38 152
en19 English Gheal 2022-01-08 21:02:08 0 (published)
en18 English Gheal 2022-01-08 20:53:28 372
en17 English Gheal 2022-01-08 17:36:05 134
en16 English Gheal 2022-01-08 17:26:10 4809
en15 English Gheal 2022-01-08 17:24:06 1808
en14 English Gheal 2022-01-08 17:22:43 708
en13 English Gheal 2022-01-08 17:20:14 820 Tiny change: 'eq 0$;\n- \neq k$.\' -> 'eq 0$;\n- $a_i \neq k$.\'
en12 English Gheal 2022-01-08 17:02:26 5 Tiny change: 'eq 0$;\n- \neq k$.\' -> 'eq 0$;\n- $a_i \neq k$.\'
en11 English Gheal 2022-01-08 17:02:02 56
en10 English Gheal 2022-01-08 17:01:18 5
en9 English Gheal 2022-01-08 17:00:59 1438 Tiny change: '="Solution>\n\nTo be' -> '="Solution">\n\nTo be'
en8 English Gheal 2022-01-08 16:57:22 6 Tiny change: '="Solution>\n\nTo be' -> '="Solution">\n\nTo be'
en7 English Gheal 2022-01-08 16:56:32 2 Tiny change: '="Solution>\n\nTo be' -> '="Solution">\n\nTo be'
en6 English Gheal 2022-01-08 16:56:14 51
en5 English Gheal 2022-01-08 16:55:40 122
en4 English Gheal 2022-01-08 16:52:11 2248 Tiny change: 'tion">\n\n\textbf{Lemma:} The numbe' -> 'tion">\n\n**Lemma:** The numbe'
en3 English Gheal 2022-01-08 16:47:07 13 Tiny change: 'tion">\n\n\textbf{Lemma:} The numbe' -> 'tion">\n\n**Lemma:** The numbe'
en2 English Gheal 2022-01-08 16:46:52 797
en1 English Gheal 2022-01-08 16:46:10 1652 Initial revision (saved to drafts)