By vintage_Vlad_Makeev, history, 23 months ago, , Besides the editorial we prepared some challenges for you.

(Idea — MikeMirzayanov, developing — fcspartakm)

(Idea — _meshanya_, developing — Zlobober, KAN)

(Idea — Zlobober, developing — ch_egor)

(Idea and developng — Sender)

(Idea — V--o_o--V, developer — Flyrise)

(Idea — Sender, developer — _kun_)

(Idea — Zlobober, developer — malcolm)

(Idea and developng — gritukan) Tutorial of Codeforces Round #469 (Div. 1) Tutorial of Codeforces Round #469 (Div. 2) Tutorial of W9 main contest Comments (19)
 » Auto comment: topic has been updated by gritukan (previous revision, new revision, compare).
 » Auto comment: topic has been updated by gritukan (previous revision, new revision, compare).
 » Auto comment: topic has been updated by gritukan (previous revision, new revision, compare).
 » "BONUS (medium): Given graph is not properly colored, but you don't have to minimize size of the set. Can you solve it?"Yes, that's what I solved yesterday before solving actual problem xD
 » "BONUS (hard): Find answer minimizing number of subsequences."Sorry if I'm missing something but isn't number of subsequences always equal to number of 0s — number of 1s, as each subsequence chosen increases number of 0s — number of 1s by 1.
•  » » 23 months ago, # ^ | ← Rev. 2 →   Yeah, you are right, it was a joke :)
 » The two bonuses for "Binary cards" are the same, should they be?
•  » » Oops, my bad. It should be n ≤ 105 in the second challengle. I'll fix it now.
 » 23 months ago, # | ← Rev. 4 →   "BONUS (medium): Given graph is not properly colored, but you don't have to minimize size of the set. Can you solve it?"If a person stores his data at computers x and y and initially colorx = colory then if x is in the set we choose then y won't. Similarly if y is in the set then x won't. This is NAND 2-Sat clause. Additionally like in the statement we add directed edges for the cases — they are equivalent to implications.Well now for the medium problem we simply need to find a valid 2-SAT solution with at least 1 variable true. Well we simply try fixing all possible variables to be true and then check for a solution. This way we achieve . Probably there is a faster way to do it but still this should work.The main reason for this comment is because I think I have a solution for the hard version. Not sure it's correct tho.So let's assign costs to the vertices. We assign a cost of -1 to all variables x and a cost of 0 to . Now we search for a 2-SAT solution of the maximum cost with at least on 1 set to the original variables. Well this should be possible to be solved with the Maximum closure algorithm. We again try fixing every variable and then running the algorithm.The overall complexity will be . UPDATE: it's wrong.
 » It seems I have a solution for E that's linear in N and almost independent on (just through polylog).The extra observation is that when we decide to use cards for the first k bits and skip the card for bit k + 1, we can shift each Ai by any number in a common fixed range [l, l + 2k) that contains 0 — the value of l can be chosen arbitrarily by setting the cards' signs. This shift needs to make each Ai divisible by 2k + 1, but since we can only shift by at most 2k - 1, the number we need to shift to is uniquely determined. This tells us a possible value of l for a given k (or that it doesn't exist).This gives an obvious recursive, possibly exponential solution: try all possible k, shift each Ai and divide by 2k + 1, solve for this modified array recursively if it's possible to choose a valid l (stopping when everything is 0) and add k cards; choose the option that gives the fewest cards.Now, intuition says we could take the first k that gives a valid l and set of shifts. I don't have proof this works, but I submitted it and got AC. (In fact, I got AC even with the possibly exponential solution. Idk if it can be hacked or the tests aren't strong enough?) Either way, since the recursion doesn't fork, this is clearly .