### MateoCV's blog

By MateoCV, history, 6 months ago,

Hola Codeforces!

I am happy to invite you to Codeforces Round #774 (Div. 2), which will take place on Mar/04/2022 18:35 (Moscow time). Notice the unusual time! The round will be rated for participants with rating lower than 2100. You will have 2 hours to solve 6 problems. The problems were authored and prepared by me.

I would like to thank the following people who made the round possible:

See you in the standings!

UPD:

Scoring distribution: $750$ — $1000$ — $1250$ — $2000$ — $2500$ — $3000$

Thanks to ak2006, video editorials for some of the problems will be available on his channel after the round.

UPD: Editorial

UPD: Congratulations to the winners!

Official winners:

Unofficial winners:

• +643

 » 6 months ago, # |   +16 Good luck and high rating.
 » 6 months ago, # |   -48 Good luck to all Ukrainian contestants
•  » » 6 months ago, # ^ |   -94 Why doesn't Ukrainian contestants boycott this Russian website?
•  » » » 6 months ago, # ^ |   +14 use grammarly
•  » » » » 6 months ago, # ^ |   0 bruhh lol xd
•  » » » 6 months ago, # ^ |   +4 how did you reach candidate master without common sense?
•  » » 6 months ago, # ^ | ← Rev. 2 →   +3 down! Charon here
 » 6 months ago, # | ← Rev. 2 →   +4 Note The Unusual Timings (1 Hour Late) :)GL and wishing you all +ve delta
 » 6 months ago, # |   0 gl ^ hf
•  » » 6 months ago, # ^ |   +25 good luck ^ have fun = 0:)
•  » » 6 months ago, # ^ |   +7 This was such a hint and everybody ignored it smh
 » 6 months ago, # |   +1 best of luck for all♥️
 » 6 months ago, # | ← Rev. 2 →   -15 Good luck and positive rating!!!
•  » » 6 months ago, # ^ |   -18 why are you disliking him?
•  » » » 6 months ago, # ^ |   +1 Mike Top. I wanted to make a joke
 » 6 months ago, # |   0 This will probably be my first contest in over a month...I'm awaiting -100 delta :P
•  » » 6 months ago, # ^ | ← Rev. 3 →   0 same... I'm awaiting losing my green after my first contest :P glthat wasn't true gonna get +20 :yayy:
•  » » » 6 months ago, # ^ | ← Rev. 2 →   0 let's go! i'm having my series of defeat tooi overslept so i didn't participate
•  » » » 6 months ago, # ^ |   0 Losing Vir-greenity... Btw I am also hoping for the same :)
 » 6 months ago, # |   +10 Good luck everyone. Maybe this round will help improve people's mood at codeforces.
•  » » 6 months ago, # ^ |   -20 hello gagan plz guide me as i am stuck in newbie-pupil phase from a long long time and i don't see improvement also provide tips for dp if any. thnx in advance.
•  » » » 6 months ago, # ^ | ← Rev. 2 →   +1 The key to improvement is indeed just good-old practice. Now, everyone should choose a practice regime which suits them well. I just like you were shuffling pupil and newbie for 1 year. This year I started practicing more with a focus on solving questions rather than learning new algorithms. You only need a handful of algorithms like dfs-bfs, Dijkstra, dsu, segment tree to reach the expert but dp practice is very important. I practiced dp from problemset with filter-tag and started solving from 1000 rated questions and gradually increased rated questions. When I felt like I can do 1600 rated dp questions pretty confidently then I started randomly doing questions with gradually increasing difficulty from 1000 to 1600. Make sure you actually solve the questions and don't see the editorial until you solve it. If it seems impossible then try to read other people's code before checking out editorials. Do cp with your friends, discuss approaches and try to outrank your peers :p. This is what has worked for me till now, hope this helps you. Good luck!
•  » » » » 6 months ago, # ^ |   0 I think DP is the most important thing. segment tree is not too important at pupil stage.
•  » » » » » 6 months ago, # ^ |   0 I was talking about the concepts which can land you to expert level.
•  » » » » » » 6 months ago, # ^ |   +4 expert level doesn't need segment tree to be fair, binary search, greedy, simple DP, DFS/BFS and a little knowledge of graph.
•  » » » 6 months ago, # ^ |   0 HelloSame for me i am stuck at newbie stage for last 2-3 months i have been doing it consistency with avg daily 4-5 of 1300 rated questions but still sometimes i am unable to solve or come up with an approach even for B of div 2 or with CHelp appreciated
 » 6 months ago, # |   +8 Maybe we have the opportunity to just focus on this round itself!
 » 6 months ago, # |   0 Look at the quality of the questions. My hands are too slow.Orz
 » 6 months ago, # |   0 Before the usual time was 16:35, then 15:35, then 11:35 ... What is the actual usual time ?
•  » » 6 months ago, # ^ |   +6 9:05 PM in IST, really good for indian contestents, we don't have to shift our dinner this time.
•  » » » 6 months ago, # ^ |   0 Tatakae
•  » » » » 6 months ago, # ^ |   0 TATAKAE! TATAKAE!!
•  » » 6 months ago, # ^ |   +1 15:35 winter time, 16:35 summer time
 » 6 months ago, # |   +4 ooo thanks
 » 6 months ago, # | ← Rev. 2 →   +3 Are we going to fight against "Robot" in this round?
 » 6 months ago, # |   0 I hope I am able to do the third question at least in this round :)
 » 6 months ago, # |   +7 May C problem be solved by less than 2000 people. I want it to be an interesting one.
•  » » 6 months ago, # ^ |   +3 Bruh This is every Cyan dream . That it has less than 2000 solves and we are among them . But sadly cheaters will never make it happen ;_;
•  » » » 6 months ago, # ^ |   0 I would say and pupil too — last 3 contests happens to me top 1000 after A,B (top 100 last round), and then somehow stuck on C, and -∆, -∆, -∆
 » 6 months ago, # |   0 score distribution plz :)
 » 6 months ago, # |   +59 First argentinian contest! Congratulations MateoCV
 » 6 months ago, # |   +1 Contest after long time.Eager to participate
 » 6 months ago, # |   -63 Let's Pray for Ukrain and hope good for the world
 » 6 months ago, # |   +8 Good luck everyone! Have a good contest!
•  » » 6 months ago, # ^ |   0 You too my friend !
 » 6 months ago, # |   +4 Argentinian round? Aguante el Diego, Talleres y FaMaF!
 » 6 months ago, # |   0 Good job guys, good luck.
 » 6 months ago, # |   0 Good luck!
 » 6 months ago, # |   0 good luck :)
 » 6 months ago, # |   0 Unfriendly time for Chinese contestants.
•  » » 6 months ago, # ^ |   +2 you can't make everyone participate at a good time, right?
•  » » » 6 months ago, # ^ |   +3 Of course.Good luck to all contestants around the world.
•  » » 6 months ago, # ^ | ← Rev. 2 →   -14 dead meme
 » 6 months ago, # |   -6 Finally a CF round after long time. All the best everyone.
 » 6 months ago, # |   -17 This contest will be harder than previous contest!!!
 » 6 months ago, # |   +20 Dear contest, How do you feel today? Yet another person commented on your announcement page rn (me). Since I said hi to you, please give +ve this time to me. yk the usual. thanks in advRegards, that random user asking for +ve in rating
 » 6 months ago, # | ← Rev. 2 →   0 Very cool scoring distribution 1000 — 750 = 1250 — 1000 , 3000 — 2500 = 2500 — 2000
•  » » 6 months ago, # ^ |   +3 Dam bro, did you just invented arithmetic progression.
•  » » » 6 months ago, # ^ | ← Rev. 2 →   0 Something like that LOL :)
 » 6 months ago, # |   +1 there is no as a tester comment.
 » 6 months ago, # |   0 How many of you logged in at the usual time?
 » 6 months ago, # |   0 SpeeeeedForcesssss
•  » » 6 months ago, # ^ |   +1 why? the number of people who solved C isn't high or too low
•  » » » 6 months ago, # ^ |   0 3000+ is alot
 » 6 months ago, # |   0 antonforces
 » 6 months ago, # |   +57
•  » » 6 months ago, # ^ |   +11 D seemed near yet was so far.
•  » » » 6 months ago, # ^ |   +9 Same with E :)
 » 6 months ago, # |   0 I haven't coded recursive code in 2 years lol good to remember it with problem C
•  » » 6 months ago, # ^ |   0 I did it without recursion
•  » » » 6 months ago, # ^ |   0 How?Plz share your approach..
•  » » » » 6 months ago, # ^ | ← Rev. 3 →   +1 Store the factorials numbers <=1e12 in an array (I think the count of them is 13 or 14)Just iterate on all subsets of them (by iterating from 0 to 214) and then subtract the factorials number from n (let's call the resulting number as temp). After each subset, count the number of set bits in temp. This will be the number of powers of 2 required. Do this for all and keep track of min so far. Submission https://codeforces.com/contest/1646/submission/148374185
•  » » » » » 6 months ago, # ^ |   0 you mean factorials?
•  » » » » » » 6 months ago, # ^ |   0 My bad, dk why I typed fibonacci. Corrected it.
•  » » » » 6 months ago, # ^ |   0 Solved it using bitmask dp on factorials <= 1e12 and pop count
•  » » » » » 6 months ago, # ^ |   +1 I don't think there is any DP in your solution :p.
•  » » » » » » 6 months ago, # ^ |   +1 sorry used bitmasks to generate all possible subsets of size 15 :)
•  » » » » » » 6 months ago, # ^ |   0 Why did the setters confuse with -1 where ans is always possible?
•  » » » » » » » 5 months ago, # ^ |   0 Just to check that we are smart enough to think that . As its quite obvious that every no can be represented in binary form. So there no chance for answer to be -1.. But some ppl i saw do handle that case ;_;
•  » » » 6 months ago, # ^ |   0 I think it's still the same complexity recursion can be done in a different approach of course
•  » » 6 months ago, # ^ |   0 I did with a mask-compressed DP...
 » 6 months ago, # |   +3 It took me 2WA's and 50 minutes to figure out that for long long integers __builtin_popcount doesn't work and we need to use __builtin_popcountll ... :-/
•  » » 6 months ago, # ^ |   +2 I realized it just before click submit button...
•  » » » 6 months ago, # ^ |   +3 I am just happy that at least I figured it out before the contest ended :)
•  » » 6 months ago, # ^ | ← Rev. 2 →   -7 You should keep such things as #define (macro), easier to remember
•  » » » 6 months ago, # ^ |   0 Missed this one ... will add it now
•  » » 6 months ago, # ^ | ← Rev. 3 →   +1 I suggest using std::popcount(). The only issue with this function in terms of competitive programming is that it requires x to be of unsigned type, so we have to cast explicitly if x is long long. int popcnt = popcount(uintmax_t(x)); Of course, the simple macro solves this problem: #define popcnt(x) popcount(uintmax_t(x)).
•  » » » 6 months ago, # ^ |   0 Thanks!
 » 6 months ago, # |   +17 5th test case of problem D...
 » 6 months ago, # |   0 it was so fun to write 15 nested for loop in problem C(p.s. I know recursive solution would also work)
•  » » 6 months ago, # ^ |   0 that means you don't know this
•  » » » 5 months ago, # ^ |   0 I mentioned fun, actually you don't know what I know so please read comments carefully next time
•  » » » » 5 months ago, # ^ | ← Rev. 2 →   0 this is not a recursive solution, it is using bitmasks.
 » 6 months ago, # | ← Rev. 4 →   +67 Imagine wasting 20 mins debugging E because you "simplified" $\frac{lcm(x_1, x_2, \ldots, x_k)}{x_1}$ to $lcm(x_2, \ldots, x_k)$ without thinking properly T_T.Also I can't exactly describe it, but CDE feel like they are somehow standard yet fairly interesting at the same time. Maybe its because they have extremely simple and natural formulations which don't feel like they've been forced to match an idea?
 » 6 months ago, # |   +3 A nice contest for me!! I loved the problem C. Would love to share my experience while solving problem C,Initially after reading the problem , I immediately thought of solving it using subset generation through bitmasks , because i thought the size of factors + powers of 2 would be around 30 , but turned out it was ~52. So i drifted a bit & thought of solving it using DP(using coin change approach) but that is also not feasible.Solution : SpoilerSome more thinking : Hmm, the number of factorials till 1e12 is ~15. Just subset generate over it using bitmasks. The remaining number will be (N — (sum of factorials in the subset)). We use the fact , that any number can be represented as the sum of powers of 2(the number of set bits in it), so the number of set bits in the remaining number is the number of powers of 2 we need. So we just try over it & find the minimum number of powerful numbers required.
•  » » 6 months ago, # ^ |   0 you only need to bitmask factors, then greedy choose powers of 2 for the rest.
•  » » » 6 months ago, # ^ |   0 Yup, thats what i did. I don't think you need to greedy choose powers of 2 for the rest , because the remaining number's binary representation containing the set bits already is the least number of powers of 2 required to represent it.
 » 6 months ago, # |   0 Logic for C?
•  » » 6 months ago, # ^ |   0 Note that n can allways be constructed with number of its bits, since these are powers of 2.So construct all possible sums of factorials (that are at most 2^14 since there are only 14 factorials in range), subtract each one from n and count the bits of the difference.Smallest number of set bits in difference plus bits in factorial sum is ans.
•  » » » 6 months ago, # ^ |   0 Thanks...!
 » 6 months ago, # |   0 How to do F?
 » 6 months ago, # |   +5 What d hell is test case 5 of D -_-
•  » » 6 months ago, # ^ |   +11 Either a large graph or something that kills the incorrect bipartite idea I guess.Try the following graph if you don't get why bipartite is incorrect: Input Graph10 1 2 1 3 1 4 1 5 1 6 6 7 6 8 6 9 6 10 Answer8 10 1 1 1 1 1 1 1 1 1 1
•  » » » 6 months ago, # ^ |   0 Thanks sir. got my mistake <3
•  » » 6 months ago, # ^ |   0 There are cases where it is optimal to not take two neighboring nodes. Splitting the tree to a bipartite graph and then taking one of the two parts is not always optimal. The idea is similar to the well-known DP problem "Maximum sum over array such that no two elements are adjacent" but implemented on a tree.
•  » » 6 months ago, # ^ |   +24 2,3-dimethylbutane
 » 6 months ago, # |   0 My Idea for D : Take all leaves to be good vertices Now all parents of the leaves (call it buds) are assigned with weight = 1 Now the graph is split into separated sections with "buds" as boundaries for each section For each section, I solve them independently by coloring it "bipartitely". In each section, I find which gave me the best arrangement whether the color "black" / "white" on this section are good vertexes and bad vertices for its counter-color. I got WA on pretest 6. Not sure if the idea is wrong or my implementation My submission : 148381092 Any thoughts?
•  » » 6 months ago, # ^ |   0 I tried the same thing (but failed pretest 5) :(
•  » » 6 months ago, # ^ |   +1 it is true that a good vertex(blue) must be surrounded by bad vertices(black) but it is not necessary that bad vertices be adjacent to good vertices. so if u two color the tree, u wouldn't take into consideration cases where two adjacent nodes are bad
•  » » 6 months ago, # ^ |   0 Pretty sure it's finding the max independent set.
•  » » » 6 months ago, # ^ | ← Rev. 2 →   0 I did it in sort of dp style. Rooted the tree at 1.dp[i][0] = means ith node is not good and fill its children however you want such that max good vertices below my subtree is C with sum of edges as S.dp[i][1] = means ith node is good and fill its children however you want such that max good vertices below my subtree is C with sum of edges as S. For transitions dp[i][1] depends on dp[c][0] where c is children of i since you are good, children can't be good.dp[i][0] picks dp[c][0] or dp[c][1] according to which is best.
•  » » » » 6 months ago, # ^ |   0 did it work ? i tried the same thing but kept getting WA in pretest 5 or 6
•  » » » » » 6 months ago, # ^ |   0 You also need to keep track of the cost in case dp[i][0]==dp[i][1].
•  » » » » » » 6 months ago, # ^ |   +3 Yeah the reason for storing S in the dp is to handle the case of dp[c][0] == dp[c][1]
•  » » 6 months ago, # ^ | ← Rev. 3 →   +1 How does the problem change after removing all the leaves?If there exists some tree for which bipartite doesn't work, I can just create a new tree by attaching a single node to each leaf and your soln won't work for it.And try the following graph if you don't get why bipartite is incorrect: Input Graph10 1 2 1 3 1 4 1 5 1 6 6 7 6 8 6 9 6 10 Answer8 10 1 1 1 1 1 1 1 1 1 1 A Correct SolutionYour intuition of weights being degree or 1 is correct, but your actual selection of nodes isn't optimal.We want to select a maximum set of nodes, such that no two nodes are adjacent.Lets root the tree arbitrarily and for a given subtree let $dp_{x, 0 / 1}$ mean the best answer we can achieve for this subtree if the node x is selected in the set or not.Then $dp_{x, 1} = \sum_{v \in children(x)} {dp_{v, 0}} + 1$ since we can't have two adjacent nodes selected. Whereas if we're not taking the current node, it doesn't matter if children are taken or not, so $dp_{x, 0} = \sum_{v \in children(x)} {\max(dp_{v, 0}, dp_{v, 1})}$.And then the optimal answer is just ${\max(dp_{root, 0}, dp_{root, 1})}$But we also have to minimize the sum of degrees in our set, how do we do that?We can notice, that the only choice we make is in $dp_{x, 0} = \sum_{v \in children(x)} {\max(dp_{v, 0}, dp_{v, 1})}$. Here we clearly want to take the one with the larger set of nodes, but what if both are equal? Then taking the one with the smallest adjacency size is optimal.How you do this is just implementation details, my way of doing it is to store $dp_{x, 0 / 1} = {\text{max number of nodes, -(min adjacency size)}}$, then we can just continue to perform max in a similar manner to before.Implementation — 148346500
•  » » » 6 months ago, # ^ |   0 i defined dp[i][0] = max good vertices if vertex i is good and dp[i][1] for bad. and dp[i][0] = 1 + all dp[ne][1] in neighbours and dp[i][1] = max(dp[ne][0] and dp[ne][1]) for all neighbours. Is is correct ? i kept getting WA in either pretest 5 or 6
•  » » » » 6 months ago, # ^ |   0 I guess in dp[i][1] case if dp[ne][0] and dp[ne][1] are equal then how are you ensuring which one to pick to get minimum sum.
•  » » » » » 6 months ago, # ^ |   0 Yup, this is likely the issue.One way to solve this is to store the dp value as a pair $<\text{max number of nodes}, -(\text{min sum of degree})>$, then taking max works as expected.
•  » » » » » 6 months ago, # ^ | ← Rev. 2 →   0 did this as well :( 148378253
•  » » » 6 months ago, # ^ |   0 Oh I see. I get it. Thanks!
•  » » » 6 months ago, # ^ |   0 Wait, in your explanation should it be $dp_{x, 0} = max(dp_{v,0} , dp_{v,1})$ ?
•  » » » » 6 months ago, # ^ |   0 no if a vertex is good, then its neighbour cannot be good. so for dp[x][0] we only see dp[v][1]
•  » » 6 months ago, # ^ |   0 Failing testcase : Ticket 724
 » 6 months ago, # | ← Rev. 2 →   0 Could someone share their approach for B ? I tried solving it by sorting the array (minimize the Blue sum) and using prefix sum, but failed. I think this is because my approach colored all the numbers.
•  » » 6 months ago, # ^ |   0 Use sum of two smallest numbers as small sum, and biggest number as big sum.If both sums are ok ans=YES else add next smallest number to small sum, next biggest number to big sum. Repeat.
•  » » 6 months ago, # ^ |   +1 Well, I also sorted it first, and then kept on calculating Blue Sum from the start and Red Sum from the end of the array. Also, to maintain the count(Blue) > count(Red), I initialised the starting index to be 1(0-based indexing) while initialising Blue Sum to be equal to the first array element.
 » 6 months ago, # | ← Rev. 3 →   +4 submitted C in the last minutetook more than 1 hour to realize brute-forcing all subsets of factorial values is feasiblebut brute-forcing all subsets of 2-power values is infeasible which gave me a wrong intuition that the factorial counterpart is also infeasibleI hope in the future I can be more familiar with the thresholds of feasibility.
•  » » 6 months ago, # ^ |   0 Why we Can't use one factorial two times?
•  » » » 6 months ago, # ^ |   +5 because we need distinct numbers
•  » » » » 6 months ago, # ^ |   0 Got it now. I Read the question again. Sucks when missed important point.
•  » » » » 6 months ago, # ^ |   0 Please explain and share your approach!
•  » » » 6 months ago, # ^ |   0 That would make it way harder so be glad about it
•  » » » 6 months ago, # ^ |   +1 the problem description said distinct.
•  » » 6 months ago, # ^ |   +3 Even if it was feasible to brute force all powers of 2, how would you find the needed amount of factorials?
•  » » » 6 months ago, # ^ |   0 I don't know how to find the needed factorials except for brute-force, so I should have taken that approach initially. Unfortunately the infeasibility of brute-forcing 2-powers gave me the wrong intuition that brute-forcing factorials is also infeasible.
•  » » » 6 months ago, # ^ |   0 No Idea. That is why I was not able to solve C. Was expecting there is some other trick to solve the problem which I was not able to think.
•  » » » 6 months ago, # ^ |   +1 There are not much factorials in range, it is only 14 numbers. So you can create only 2^14 sums from these numbers. Just try all of them.
•  » » 6 months ago, # ^ |   0 Went through the same trajectory, except I took even more time to realise this and couldn't submit my code in time :( It also somehow escaped by mind that combinations of powers of 2 literally define every single number in exactly one possible way.
 » 6 months ago, # |   +3 Thanks for the contest, I don't know why I did so dumb on A and B, But after all I really liked the problems.
 » 6 months ago, # |   0 In c, finding all the numbers powerful in a set then take a number which are just less than n and subtracting them from n is not feasible why?
•  » » 6 months ago, # ^ | ← Rev. 2 →   +1 For 184 the correct answer is 120 + 64 but your approach would yield 128 + 32 (edited from 56) + 24.
•  » » » 6 months ago, # ^ |   0 How did you get 56 here....
•  » » » » 6 months ago, # ^ |   +1 184 — 128 = 56. The point is that you can't pick the max number <= n.
•  » » » » » 6 months ago, # ^ |   0 But 56 won't be in set, so it would look like 184 → 128 + 32 + 24 (wrong approach)
•  » » » » » » 6 months ago, # ^ |   +1 Ah sorry, I meant 128 + 32. Thanks :)
 » 6 months ago, # |   +5 what is pretest 6 of D? ಥ_ಥ
•  » » 6 months ago, # ^ |   +4 If you were doing BFS solution from leaves, It would fail. Optimal solution will be reached by dynamic programming.
 » 6 months ago, # | ← Rev. 2 →   +14 I think D is just Maximum Independent set with least total degree which can be solved by dp. I realised this, but could not reconstruct the solution from the dp before the contest ended.
 » 6 months ago, # |   0 How to solve E? I was looking for numbers with the same prime factors
•  » » 6 months ago, # ^ |   0 Take 2, 4, 8, ... as example. In the row starting with 2, you get 2^1, 2^2, ... In the row starting with 4, you get 2^2, 2^4, ..., so what in the cells are these powers of 2: 1 ~ M, 2 * 1 ~ 2 * M, 3 * 1 ~ 3 * M, ..., depending on how many powers of 2 are less than or equal to N. Then, what you need to do is calculate how many distinct number is in this list. Sum up all the length of lists of a number that is not power of another one. Don't forget 1.
 » 6 months ago, # |   0 Any counterexample on D solving with 2-coloring?
•  » » 6 months ago, # ^ |   +3 6 1 3 2 3 3 4 4 5 4 6
•  » » 6 months ago, # ^ |   +3 61 21 31 44 54 6The output should be:4 61 1 1 1 1 1 The idea is that although there can be no 2 adjacent good nodes, this does not mean that there can be no 2 adjacent bad nodes. Unfortunately I realized that a short time just before the contest ended.
•  » » 6 months ago, # ^ |   +3 Input Graph10 1 2 1 3 1 4 1 5 1 6 6 7 6 8 6 9 6 10 Answer8 10 1 1 1 1 1 1 1 1 1 1 VisualizationTake all the leaves.
 » 6 months ago, # | ← Rev. 2 →   0 Hey, In the first problem, why this works cout << s/(n*n) << '\n'; but using cout << (int)(s/pow(n,2)) << '\n'; gives wrong answer in test 2?
•  » » 6 months ago, # ^ |   +17 because pow() returns double which may cause precision issue.
•  » » » 6 months ago, # ^ |   0 Oh, thank you!
•  » » 6 months ago, # ^ | ← Rev. 2 →   0 It turns out s/(n*n) is bounded within INT_MAX because bounds of s depend on n. Problem was caused due to precision issue of pow() as Aging1986 pointed out.
 » 6 months ago, # |   +9 tried dp in D but it doesn't work... so retried bipartite and failed again.
•  » » 6 months ago, # ^ |   +1 Dp does work in D, as long as you remember the secondary condition of min sum of degree. Submission — 148346500
•  » » » 6 months ago, # ^ |   0 Yes, that’s why I failed.
 » 6 months ago, # |   0 Is it possible to output -1 in c ??
•  » » 6 months ago, # ^ |   +3 no, any number can be represented as sums of powers of two (its binary representation).
 » 6 months ago, # |   0 Getting MLE on test 39 on problem D just because I used longs and a relatively high memory constant is the most unfair thing ever...
 » 6 months ago, # |   0 Auto comment: topic has been updated by MateoCV (previous revision, new revision, compare).
 » 6 months ago, # |   0 Auto comment: topic has been updated by MateoCV (previous revision, new revision, compare).
 » 6 months ago, # |   0 Nice contest!
 » 6 months ago, # |   +29 Ratings updated preliminarily. We will remove cheaters and update the ratings again soon!
 » 6 months ago, # |   0 Would this idea work for D? ideaHave some structure that keeps pairs {rank of vertex, vertex} sorted — eg. set. 'rank of vertex' is number of vertex's neighbors that have no weight assigned yet.Now while there are vertices with no weight assigned do:take vertex with smallest rankfor every neighbor of this vertex that has no weight — assign weight 1 to themassign weight to our vertex — weight will be number of neighborsfor each neighboring vertex reduce their rank by one and update our structure accordinglySo this algorithm would work something like Kruskal. I think only difference is this weird updating of ranks.
•  » » 6 months ago, # ^ | ← Rev. 3 →   +3 It won't workEdit:Actually I don't know.Edit2:I've coded it — it doesnt find the minimal value correctly.
 » 6 months ago, # |   0 Hi in problem C this solution i want to get minimum number of distinct integers their sum equal to n in vector (fact) how can i do that : code : https://ideone.com/sjl5Od
 » 5 months ago, # |   0 Finally, contest with a normal time :D
 » 5 months ago, # |   0 Finally got rated :)
 » 7 weeks ago, # |   0 can we solve problem c using dynamic programming