Andrew Stankevich Contest 36 Editorial

Правка en31, от 0mar, 2026-01-28 23:12:51

Contest link: https://mirror.codeforces.com/gym/100430    

100430A - Chip Installation

Solution

100430B - Divisible Substrings

Solution

100430C - Preparing Documents

Solution

100430D - GridBagLayout

Solution

100430E - Hot Potato Routing

Solution

100430F - Knapsack Problem

Solution

100430G - Magic Potions

Solution

100430H - Restoring Permutation

Spoiler

100430I - Roads

Solution

100430J - Squary Set

Suppose we have a set $$$X = {a_1,\dots,a_k}$$$ satisfying the problem's conditions. Then notice that $$$n - a_i = x^2 \to n-x^2=a_{i}$$$ for some integer $$$x$$$. So you can transform the problem into the following: Given the set of coins

Unable to parse markup [type=CF_MATHJAX]

Unable to parse markup [type=CF_MATHJAX]

such that the sum is $$$n$$$. Since there are at most $$$\sqrt{ n }$$$ coins, this can be solved with knapsack in $$$O(n\sqrt{ n }k)$$$. If implemented efficently, this might pass, however you can optimize the solution to be $$$O\left( \frac{n\sqrt{ n }k}{w} \right)$$$ using bitsets. The dp can be formulated as: $$$dp[i][j]$$$ indicates whether or not you can get to sum $$$i$$$ with a subset of size $$$j$$$. You must also maintain after every adding a coin which new sums are possible, which can be implemented using std::bitset's find_first and iterating over newly set bits. Note that reconstructing the answer greedily doesn't work although it might pass Counterexample: 3651 4

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en36 Английский diss_quack 2026-01-29 02:09:27 0 (published)
en35 Английский 0mar 2026-01-29 01:37:05 6 type for J
en34 Английский diss_quack 2026-01-29 01:30:47 6
en33 Английский diss_quack 2026-01-29 01:26:25 41
en32 Английский 0mar 2026-01-28 23:16:26 36
en31 Английский 0mar 2026-01-28 23:12:51 964
en30 Английский diss_quack 2026-01-28 20:26:06 885
en29 Английский ezraft 2026-01-28 19:50:26 146
en28 Английский ezraft 2026-01-28 19:22:57 747
en27 Английский ezraft 2026-01-28 19:05:23 25
en26 Английский ezraft 2026-01-28 19:04:37 5
en25 Английский ezraft 2026-01-28 19:04:00 3351
en24 Английский ezraft 2026-01-28 18:55:02 90
en23 Английский diss_quack 2026-01-14 22:11:54 772
en22 Английский diss_quack 2026-01-14 20:55:29 29
en21 Английский diss_quack 2026-01-14 20:54:21 275
en20 Английский diss_quack 2026-01-14 20:51:21 225
en19 Английский diss_quack 2026-01-14 20:46:23 1179
en18 Английский 0mar 2026-01-14 08:31:30 6
en17 Английский 0mar 2026-01-14 08:30:46 13
en16 Английский 0mar 2026-01-14 08:29:49 1584 add H editorial
en15 Английский diss_quack 2026-01-14 00:00:09 3020
en14 Английский diss_quack 2026-01-13 23:08:11 16
en13 Английский diss_quack 2026-01-13 23:04:07 3121
en12 Английский ezraft 2026-01-13 22:43:35 22
en11 Английский ezraft 2026-01-13 22:36:51 97 Tiny change: 'A \subset \{1, \ldots, n\}$ we intr' -> 'A \subset {1, \ldots, n}$ we intr'
en10 Английский ezraft 2026-01-13 22:26:58 1267
en9 Английский ezraft 2026-01-13 21:41:35 248
en8 Английский ezraft 2026-01-13 21:39:13 6 Tiny change: 'add $x = \argmin_{u \in \{' -> 'add $x = \text{argmin}_{u \in \{'
en7 Английский ezraft 2026-01-13 21:38:19 667
en6 Английский ezraft 2026-01-13 21:30:26 4 Tiny change: 'et $A$ is `constrained` if $s(A) ' -> 'et $A$ is _constrained_ if $s(A) '
en5 Английский ezraft 2026-01-13 21:30:00 8
en4 Английский ezraft 2026-01-13 21:28:53 64
en3 Английский ezraft 2026-01-13 21:28:13 1414
en2 Английский ezraft 2026-01-13 21:13:02 44
en1 Английский ezraft 2026-01-13 21:12:14 416 Initial revision (saved to drafts)