### Fedosik's blog

By Fedosik, history, 4 years ago, translation,

Hi everyone!

We invite you to participate in Codeforces Round #429, wich will take place on August 18th, 18:05MSK.

The problems were set by Fedor Fedosik Korobeinikov and Vlad totsamyzed Mosko. Special thanks to Alex netman Vistyazh for helping to prepare the round, Alex AlexFetisov Fetisov and Vladislav winger Isenbaev for testing problems, Mike MikeMirzayanov Mirzayanov for Codeforces and Polygon systems.

Participants of both divisions will be given 5 problems and 2 hours to solve them. Scoring will be announced before the round.

We hope you'll enjoy our round! We wish everyone good luck and high rating!

UPD: The scoring is: 500 — 1000 — 1500 — 2000 — 2500. Note, that number of tasks changed from 6 to 5. Also great thanks to Alex Um_nik Danilyuk for testing problems.

UPD: We are really sorry for our awful english statements.

UPD: The round is finished. Sorry for inconvenience again. Congratulations to the winners:

Div1:

Div2:

UPD: Editorial.

• +253

 » 4 years ago, # |   +92 Let's hope cp will become a real sport. And let's hope for short statement too :))
•  » » 4 years ago, # ^ |   +48 After all Hope is a good thing, maybe the best of things! :')
•  » » » 4 years ago, # ^ |   +18 And no good thing ever dies! :')
 » 4 years ago, # |   +32 Short announcement, short problem statements. Hopefully.
•  » » 4 years ago, # ^ |   0 Boy you were so wrong.
•  » » » 4 years ago, # ^ |   0 Unfortunately yes. Though long statements wouldn't be a big problem themselves...
 » 4 years ago, # |   +49 There is a codesprint on Hackerrank one hour in the midway of this contest.
•  » » 4 years ago, # ^ |   +48
•  » » » 4 years ago, # ^ |   +236
•  » » » » 4 years ago, # ^ | ← Rev. 2 →   -32 Is he from Game of thrones?
•  » » » » » 4 years ago, # ^ |   +37 It's from LotR. See here.
•  » » » » » 4 years ago, # ^ |   +38 One doesn't simply walk into Mordor from Westeros.
•  » » » » » » 4 years ago, # ^ |   +53
•  » » 4 years ago, # ^ |   +65 Assuming that any contest clashes with a CF contest, It can only be bad for the clashing website and not for CF.If HackerRank care enough about their own, they should change timings, not CF.
•  » » » 4 years ago, # ^ |   +11 I kinda disagree as there is prize money for the top 7, so those top rated participants might go for that instead.
•  » » » 4 years ago, # ^ |   0 just look at the leaderboard on hackerrank. and then say a word bro... Gennady finished the entire contest in 29 minutes. It took me more than half hour to understand all the problems properly.
•  » » 4 years ago, # ^ |   0 It's a two day contest, that's probably why this round didn't yield way.
•  » » » 4 years ago, # ^ |   +18 but the first hour is the important timing for those who wants to win top places(not me of course)
•  » » 4 years ago, # ^ | ← Rev. 3 →   +21 Never mind.
 » 4 years ago, # |   -6 Who will be the main character of the round?
 » 4 years ago, # |   -19 New round, means new chance for better performance and improving our rate.
•  » » 4 years ago, # ^ |   +3 Chance of learning new things
 » 4 years ago, # |   +118 I think the winner is obvious.
•  » » 4 years ago, # ^ |   -37 Not after Rudy998244353 registred.
•  » » » 4 years ago, # ^ |   +2 they are not even the same division
•  » » » » 4 years ago, # ^ |   -46 He just doesn't want to scary tourist, that's why he participate in div 2.
•  » » » » » 4 years ago, # ^ | ← Rev. 2 →   +74 Why so salty man? Still mad that you sucked at IMO?UPD: WTF I was not expecting upvotes.
•  » » » » » » 4 years ago, # ^ |   -33 Why is it salty? Did i offend aomeone?
•  » » » » » » » 4 years ago, # ^ |   -13 Anyone who knows sarcasm will understand it. Can't understand if you really hate him, because he did better than you at IMO or you're joking too hard.
•  » » » 4 years ago, # ^ |   0 nibabin registered too so I got no chance :'( Although I heard there are problems that even he can't solve
 » 4 years ago, # | ← Rev. 2 →   -6 tank you all for contest. and hope for statement be as short as blog.
•  » » 4 years ago, # ^ |   -33 R.I.P English
•  » » » 4 years ago, # ^ |   0 Sorry for bad english :)
 » 4 years ago, # |   +11 Where is KAN?
 » 4 years ago, # |   0 Hi , I just wanted to ask that whats the difference in div 1 and 2 like can we say that Div 2 E,F > Div 1 A,B,C,D in terms of difficulty?
•  » » 4 years ago, # ^ |   +20 Usually, Div 2 C/D/E.. is the same as Div 1 A/B/C.. and so on. The difficulty is in the increasing order.
 » 4 years ago, # |   0 this is the shortest announcement I have ever seen !!
 » 4 years ago, # |   0 Are 2 hours good for 6 problems ?
•  » » 4 years ago, # ^ |   -6 do you want to full ?
•  » » » 4 years ago, # ^ |   +12 What do you think bro, my color still f*ckin gray :3
•  » » » » 4 years ago, # ^ |   0 We don't judge people by their color here <3
•  » » » » » 4 years ago, # ^ |   +13 Sharon are you sure ? :"D link1 link2
•  » » » » » » 4 years ago, # ^ |   +25 All colors are equal, but some are a bit more equal.
•  » » » » » » » 4 years ago, # ^ |   +3 Good, I'll try make website and make the rate by hair color so you know overages coders will be gray newbies
•  » » » » » » » 4 years ago, # ^ |   0 Animal farm..
 » 4 years ago, # |   +68 I wonder what is the story behind your rating graph, totsamyzed. Are you going to be our next dreamoon_love_AA?
•  » » 4 years ago, # ^ |   +11 I think this guy is also hero
 » 4 years ago, # |   -116 Thanks a lot for sharing it, that’s truly has added a lot to our knowledge about this topic. Have a more successful day. Online Economics Assignment Help from Professionals
 » 4 years ago, # | ← Rev. 3 →   -32 I hope we will have an interesting contest tonight:) GL
 » 4 years ago, # |   +18 OMG :O GoodGuy Registered for this contest :O
•  » » 4 years ago, # ^ |   +19 Who is he? :/
•  » » » 4 years ago, # ^ | ← Rev. 2 →   +24 he is sad ,he is hurt ,he is dying ,he is lonely ,he is a mess ,he is judged ,he is ignored ,he is suicidal ,he is depressed ,he is misunderstood ,he is tired he is SmSS
 » 4 years ago, # |   -12 Kool(Sorry for my bad english)
•  » » 4 years ago, # ^ |   +15
•  » » » 4 years ago, # ^ |   0 London is the capital city of Great Britain
•  » » » » 4 years ago, # ^ |   +3 ?
 » 4 years ago, # |   0 Why was number of problems changed?
•  » » 4 years ago, # ^ |   +4 because time was not good for N4553R !he want to full :DLink
•  » » » 4 years ago, # ^ |   +10
•  » » 4 years ago, # ^ |   +5 Probably they found an issue with one of the problems.
•  » » 4 years ago, # ^ |   0 why not ?:)
 » 4 years ago, # |   +18
•  » » 4 years ago, # ^ |   +103 someone hack your code is so better than judge do it :D
•  » » » 4 years ago, # ^ |   +32 He'll find and kill the judge.
 » 4 years ago, # |   0 Not the right place for this post, but could some of the contest organizers or idk inform CF staff that email system isn't working. Thanks
 » 4 years ago, # |   +91 Did Um_nik save rated contest? :D
•  » » 4 years ago, # ^ |   +27 Not all heroes wear capes.
•  » » 4 years ago, # ^ | ← Rev. 2 →   +47 I hope this time the tests were weak instead of author's mind.
•  » » » 4 years ago, # ^ |   0 I don't think a lot of people get that reference.
•  » » » » 4 years ago, # ^ |   0 Check this
 » 4 years ago, # |   +34 totsamyzed, don't make us sleep during the contest.
•  » » 4 years ago, # ^ |   +10 and during system tests as well. :)
•  » » » 4 years ago, # ^ |   +10 Wish not granted :D
 » 4 years ago, # |   +18 Please open additional registration! Why is it even closed? I have not expected it would be impossible to register after the competition started
 » 4 years ago, # | ← Rev. 4 →   +64 so many spelling mistakes.having trouble guessing the meaning of div2Dand even no explanation of the Sample
•  » » 4 years ago, # ^ |   +10 took me a good 10 minutes to get it too, but what do you want, it's all part of the challenge !
•  » » 4 years ago, # ^ |   +6 I asked for clarification of sample cases. Reply was "read the statement". No i'm asking for clarification without reading the statement -_-
•  » » 4 years ago, # ^ |   0 KKpoker me too the statement was not clear for problem D
 » 4 years ago, # |   +64 RIP English
 » 4 years ago, # |   +98 I'm sorry, but these problem statements are all cancerous. When you see a red squiggly line below your text, that means you have a problem. Don't submit text with a red squiggly line under it.
 » 4 years ago, # |   +35 What the heck is F(n,k)???? So much broken english...
•  » » 4 years ago, # ^ | ← Rev. 2 →   +60 I don't get it, why do you need F(n, k) if you can guess the solution by sample cases -_-.
 » 4 years ago, # |   +79 English is my first language and I can't understand Div1 B. It's riddled with typos and the grammar doesn't make sense.
•  » » 4 years ago, # ^ |   +6 Can someone clarify: "Subset is calling «good», If we save in a graph only edges from subset , and for every vertex i will correct, taht di =  - 1 or it's degree modulo 2 is equal to di."
•  » » » 4 years ago, # ^ |   0 The English in the statement is very much "LOL".
•  » » » 4 years ago, # ^ |   0 G=(V,E) is a graph, with V its vertices and E its edges. A subset S of E is called "good" if in the new graph G'=(V,S) we have the following property: for any vertex i in V of G', we either have d_i = -1, or deg(i)%2 = d_i ("deg" meaning degree, the amount of edges in S that are incident to vertex i).(hope it helps, though it's a bit too late now i guess)
 » 4 years ago, # |   +45 With due respect to the setters, seriously, what is that? I haven't yet understood the statement of problem A and B -_- RIP English.
 » 4 years ago, # |   +319 Does anyone even proofread the problems?
•  » » 4 years ago, # ^ |   +44 Neu languache unlokt für CF: German
 » 4 years ago, # |   +19 Was excited for a rated round :/ 6 more days i guess.
 » 4 years ago, # | ← Rev. 2 →   +64 After reading ABD, I had no option other than withdrawing participation.
 » 4 years ago, # |   +35 Worst problem statements I've seen on codeforces in a long time. Very disappointing. The proofreaders are all on vacation or something?
 » 4 years ago, # |   +5 Div2 D is a total disaster. Can't understand anything! RIP English!
•  » » 4 years ago, # ^ |   0 Same here! This question was a disaster =(
 » 4 years ago, # |   +3 Horrible problem description! :/
 » 4 years ago, # |   +30 Delinur, where u at when we need you?
 » 4 years ago, # |   +23 You should really make this unrated. This is not English.
 » 4 years ago, # |   0 Horrible statements, and they're also not answering my questions. Not to mention zero shts were given with regards to the statements' coherence and story.
 » 4 years ago, # |   +14 As if we could "save in a graph only edges" from a subset... Really, how old are the proofreaders? Freaking 5?
•  » » 4 years ago, # ^ | ← Rev. 4 →   +23 Okay, this is getting ridiculous. This is what I get when I translate from English to Russian to English.Lech plays a computer game where at each level a connected graph with n vertices and m edges is given. Graph can contain multiple edges, but can not contain loops. Each vertex has an integer di, which can be 0, 1, or -1. To pass a level, it needs to find a "good" subset of the edges of the graph or say that it does not exist. A subset is called "good". If we save only edges from the subset on the graph and correct for each vertex i, that di = -1 or the degree modulo 2 is equal to di. Lech wants to pass the game as soon as possible and ask you to help him.At least that's understandable.
•  » » » 4 years ago, # ^ | ← Rev. 3 →   +8 And yet the last Announcement says "Loop is an edge like (u, u). Loops are not allowed. Cycles are allowed."
•  » » » » 4 years ago, # ^ |   +14 Loop is an edge similar to (u, u). Cycles are not allowed. Cycles are allowed.Not like this. Not like this...
•  » » » » 4 years ago, # ^ |   0 What is the problem with that?
 » 4 years ago, # |   +15 Never seen so many announcements in a single contest :/
•  » » 4 years ago, # ^ |   +27 when an announcements published I thought my solution hacked :\
 » 4 years ago, # |   +7 Thanks for closed registration
 » 4 years ago, # |   +35 Man dis, shit is aw full following time I am save Russia probs text in, google translate and read 'from they're.
•  » » 4 years ago, # ^ | ← Rev. 2 →   +3 Man, shit, complete, after I save Russia, ask for the text, translate and translate the text "from them."Well I think the best method of reading grammatically incorrect sentences is to translate to Russian and then back, I guess.
 » 4 years ago, # | ← Rev. 2 →   +50 When your problems' themes are so thin like that (really, Leha somehow found arrays and queries in pockets?), you'd better off not using any theme at all. Just state the problem without involving Leha in any way. For example, Div1D (what I mentioned above) should just be stated as "You are given an array of n numbers and q queries l r k...", so you don't need to stare awkwardly at why Leha's pockets are of any relevance.
•  » » 4 years ago, # ^ |   +38 Say what you will, I still think that"Mom brought him two arrays A and B"Is the funniest thing I've read in a long time
 » 4 years ago, # |   +20 Hands down one of the worse contests. Close to 2000 people passed pretest in C but less than 50 is able to solve D. The difficulty is so low in A,B,C that difference in ranking is explained by whoever understands the statement first.
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 The ones who did 841D - Leha and another game about graph are the ones whose speaks Russian. That's the explanation
•  » » 4 years ago, # ^ | ← Rev. 3 →   +19 Codeforces has just pulled off a codechef.
 » 4 years ago, # | ← Rev. 2 →   +14 the predictor isn't working for me .does anyone have the same problem ?
•  » » 4 years ago, # ^ |   0 yeah
 » 4 years ago, # |   +17 I jumped directly to the Problem D, its been an hour and still I am not able to understand the question at all. So many mistakes in the spelling and explanation, I am leaving this round :(
 » 4 years ago, # |   0 can someone give me brief idea of sample test 2 of Problem D , how is the answer 0 ??
•  » » 4 years ago, # ^ | ← Rev. 6 →   +15 It means: Find a sub graph of the given graph, such that for every vertices i, if d[i] != -1, then the degree of vertices i in the sub graph module 2 should be d[i].And you're asked to output the number of edges in the sub graph k in the first line, then k lines follow, indicating which edge you'd decided to remain in the sub graph. Edges are labeled in the input order.So, for test 2, a simple answer is to leave nothing in the sub graph, so 0 is acceptable. Another proper answer can be41234 BTW, this is the worst description I'd ever seen. I believe even google translate can do a better job :(
•  » » » 4 years ago, # ^ |   0 Isn't 0 good for every graph then?
•  » » » 4 years ago, # ^ |   0 So why 0 isn't good for sample 1?
 » 4 years ago, # |   0 Problem C and D (div2) are awful. They didnt even provide good sample test explanations as well. And I dont know who are the heads of CF?? I mean, come on, after all this time you should at least look at the problems before deciding it is "contest-worthy".
 » 4 years ago, # |   +1 My code gave TLE in C++11 and got PRETESTS ACCEPTED in C++14 :( Is it my fault or Is their any way so that my penalities are taken back.Please someone suggest me on this.
•  » » 4 years ago, # ^ |   +1 yeah I lost 150pts for penalty and 160pts more for wasting time until I see this comment :<
•  » » 4 years ago, # ^ |   0 time run of 2 version is different. If you use "cin/cout" in problem B without something else, I think it must be TLE...
•  » » » 4 years ago, # ^ |   0 I used Fast I/O but the result hasn't changed
•  » » 4 years ago, # ^ |   0 For me it is the same. C++14 is working well for the task Div2-B. I suppose it can be a compiler issue. If it is true, maybe it is better to remove some compilers from the testing system.
 » 4 years ago, # | ← Rev. 2 →   +6 What a shit contest. Div 2 D is hardly being understood and C is being solved by even those who might have never solved any other C in their lifetime.
•  » » 4 years ago, # ^ |   0 true, still made it harder for myself didn't read a[i] >= b[j] , hope i don't get a tle .
•  » » » 4 years ago, # ^ | ← Rev. 2 →   -7 I also got myself fucked in A because of a fucking reading mistake. And the sad part is that I locked the problem as soon as I submitted. :(Moral of the story ; Dont lock the problem unless you dont see one or two hacks in the room.
•  » » 4 years ago, # ^ |   +9 you haven't solved any C in any contest so far, so you dont have any right to comment like this
•  » » » 4 years ago, # ^ | ← Rev. 3 →   -8 I have solved C twice before too.The only thing is that, I got WA in systest in either A or B in those contests.Do your research properly from the next time.Just because someone has solved 2 problems in the past doesnt mean that it needs to be A and B only.And I was not talking about this in-fact, I meant that there are people who havent solved a C even in practice sessions, and even they have solved C today.
•  » » » » 4 years ago, # ^ |   +3 I never solved E . Not even today. It looked easy today :p
 » 4 years ago, # |   +5 Was expecting short statements but not this short...
 » 4 years ago, # |   +84 I passed Div2 C just by reading examples :D
•  » » 4 years ago, # ^ |   +23 I think most did same:)
•  » » » 4 years ago, # ^ |   +1 So.. Is there a necessarily proof that it's correct to do...whatever we did?
•  » » » » 4 years ago, # ^ |   +5 Me too
•  » » » » » 4 years ago, # ^ |   +6 F(n, k) =(n+1)/(k+1)
•  » » » » » » 4 years ago, # ^ |   +11 I have just generated values and observed the pattern
•  » » » » » » 4 years ago, # ^ |   0 why is that so? I tried to see the explanation given below but still fail to understand what is meant by the question
•  » » » » » » » 4 years ago, # ^ | ← Rev. 2 →   0 We should do something like this Each element X of 1,2,3,...,N is the smallest element in some Y(X) combinations Y consists of elements X, X+1, X+2,... NSo we should somehow compute Y'sThen apply following formula :F=sum(X*Y(X))/ZWhere Z is number of k-combinataions from N elements
•  » » » » 4 years ago, # ^ |   +1 The function F(n,k) is largest when k is 1 and smallest when k is n. So you want the difference between n and k to be as large as possible so you can maximize F(n,k). So just pair the numbers so that the sum of differences is as large as possible (I think greedy pairing works for that).It's not exactly a formal proof but I think it's correct.
•  » » » » » 4 years ago, # ^ |   +1 ​I think this would give you the sum of expected valuesWe can naively say that in order to maximise sum we need to maximise A[i] - B[i] + 1 . But that's not a rigorous proof either
•  » » » » 4 years ago, # ^ |   0 yeah, as a intuitive proof — [ more elements -> keep them in smaller groups so that each element will have more influence over the summation.]
•  » » » » 4 years ago, # ^ |   +1 Once you prove/guess that F(n_i,k_i)=(n_i+1)/(k_i+1), the question is how to maximize the sum. The answer:https://en.wikipedia.org/wiki/Rearrangement_inequalitySo to maximize in this case, we need to sort (n_i+1) and 1/(k_i+1) in the same order, which is equivalent to sorting n_i and k_i in opposite orders.
•  » » » » » 4 years ago, # ^ |   0 how is ?
•  » » » » » » 4 years ago, # ^ |   0 For each m<=n, look at the subsets of {1,...,n} whose minimum element is m. There are (n-m)C(k-1) of those (because once you choose m, you have to choose k-1 remaining numbers from {m+1,...,n}.Thus, the weighted average is the sum of m*(n-m)C(k-1) , 1<=m<=n, divided by nCk.Using some basic identities (hockey stick), this simplifies down to (n+1)/(k+1).
•  » » » » » » » 4 years ago, # ^ |   0 Yeah I was able to derive the formula , but how do you get all terms cancelled . Also what do you mean by hockey stick ?
•  » » » » » » » » 4 years ago, # ^ |   +19 https://en.wikipedia.org/wiki/Hockey-stick_identityBut after thinking a little bit... it's not even needed! There's a simple bijective proof that the numerator equals (n+1)C(k+1).If we choose k+1 numbers from {0,...,n}, and throw away the lowest number, we get k numbers from {1,...,n}. How many times does each k-set get repeated? Precisely its minimum-element number of times!
•  » » » » » » » » » 4 years ago, # ^ | ← Rev. 2 →   0 DELETED (Sorry for my mistake , I get it) .
•  » » » » » » » » » 4 years ago, # ^ |   0 Nope, if you take a subset of size k+1 of {0,...,n} and remove the lowest element, you will always get a subset of {1,...,n} of size k.
•  » » » » » » » » » 4 years ago, # ^ |   +10 I love this proof as it is so elegant and straight forward, yet, I still want to know how would you get rid of the (j*) prefix from this formula.
•  » » » » » » » » » 4 years ago, # ^ |   +14 Then use the hockey stick formula for the inner sum, and again for the outer sum.
•  » » » » » » » » » 4 years ago, # ^ |   0 Thanks, got it now. :)
•  » » » » » » » 4 years ago, # ^ |   0 "Thus, the weighted average is the sum of m*(n-m)C(k-1) , 1<=m<=n, divided by nCk."1<=m<=n? why till n? shouldn't it be till n-k+1?
•  » » » » » » » » 4 years ago, # ^ |   0 Sure. But it doesn't matter, since if m>n-k+1, the binomial coefficient will be 0 anyway.
•  » » 4 years ago, # ^ | ← Rev. 3 →   +13 This is one of the frustrating things about competitive programming that make me hesitant to participate again. It is possible to get a problem accepted without being able to argue about the correctness. In mathematics and real CS, this is nonsensical, useless and completely unacceptable.
•  » » » 4 years ago, # ^ |   +14 Competitive programming is not math/CS. (I myself am a math/CS person, but I know that in competitive programming I might not need to prove correctness. On the other hand, having math/CS background helps to give intuition whether an approach will likely be correct or not.)
•  » » » » 4 years ago, # ^ | ← Rev. 6 →   +15 It can be mathematics/CS if one takes the time to understand the reasoning. The fact that it sometimes encourages non-sense (by not requiring the contestants to actually understand their solutions) is one of the reasons I think it's sort of overrated. There have been times when I got introduced to some graph algorithms and was able to code them in a competitive programming environment without having a clue about why they worked. It's a relief that those times are over. I think many competitive programmers just use "pattern recognition" (of the form "I have encountered a similar problem before" or "the samples reveal a plausible approach") and end up ACing problems with a minimal or even nonexistent amount of the much-needed rational thinking. (Yes, I believe that is the case too for a number of competitive programmers who are highly rated on this site or even scored IOI medals and the like). Over the time, I realized that writing formal proofs and good code is more enjoyable for me than competitive programming.
•  » » » 4 years ago, # ^ | ← Rev. 3 →   +11 I think this is somewhat a fault on the problem setter's part — had they asked for the value of sum(F(A, B)) it would requires a prove for it. (Maybe they didn't asked for it since it's just Div2C .... but yeah I would rather ask for full feedback and use it as 2D or 2E)
•  » » 4 years ago, # ^ |   0 Worst Div2C ever!
•  » » 4 years ago, # ^ |   +9 same here. but C and D had the worst sample explanations ever.
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 Spent plenty of time Prooving and the greedy is correct during the contest, although I had observed the feature in the sample. Sad.
•  » » 4 years ago, # ^ |   0 how?? I am still confused as to what the question means and a lot of people have seemingly solved it by seeing the samples."Consider all possible k-element subsets of the set [1, 2, ..., n]. For subset find minimal element in it. F(n, k) — mathematical expectation of the minimal element among all k-element subsets."This statement does not make any sense to me
•  » » » 4 years ago, # ^ |   +5 Consider all k-element subsets of the set {1, 2, ..., n}. For each subset, look at the smallest element in it. For example, when n = 4, k = 2, you have the following: {1, 2} with smallest element 1 {1, 3} with smallest element 1 {1, 4} with smallest element 1 {2, 3} with smallest element 2 {2, 4} with smallest element 2 {3, 4} with smallest element 3 Define F(n, k) as the average of all these smallest elements. So .
 » 4 years ago, # |   +38 You know you are 100% sure of your solution when you lock your problem even after getting hackedphoto
•  » » 4 years ago, # ^ |   +14 Actually I got that "hacked" notification real late. After making an unsuccessful hacking attempt on someone's code, I got the notification that my code has been hacked -_- . Don't know if it was my internet problem or something else.
 » 4 years ago, # | ← Rev. 2 →   +45 I should have read the Russian statements.I don't know how to speak Russian but it can't be worse than the English statements.
 » 4 years ago, # |   0 D is easy if you can understand it. I understood it but I can't solve it :'(
 » 4 years ago, # |   +4 Is there anyone who got TLE in B div-2 just reading input and printing output
•  » » 4 years ago, # ^ |   +6 what is your language if C++ use scanf and printf
•  » » 4 years ago, # ^ |   +1 use ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
•  » » 4 years ago, # ^ |   +1 change language to c++14 if using c++11
•  » » 4 years ago, # ^ |   0 Yes T.T
 » 4 years ago, # |   +18 Me seeing the succinct statements>>>> hell yeah!After reading statements>>>> wait, what ?
 » 4 years ago, # |   +10 Problem D blew up my brain, how to solve it?
•  » » 4 years ago, # ^ |   0 I think if there is a -1 node, then an answer can always be formulated. But other than that, no clue
•  » » 4 years ago, # ^ | ← Rev. 2 →   +3 When there is a -1 vertex, you can simply do a dfs and solve it greedily. When there isn't any, if the number of 1 vertex is odd you can't solve it (the sum of degrees of the subgraph should be odd which is impossible). This is as far as I got, in the case which is left I believe you can greedily solve it aswell but I'm not sure.
•  » » » 4 years ago, # ^ | ← Rev. 3 →   +3 I'll call d[i] == 1 vertices black and d[i] == 0 vertices white.So given the case where the number of black vertices is even we can solve it greedily.We can consider any spanning tree of the graph and do a dfs, let it return 0 if the subtree is solved or 1 if it is unsolved. Hence Black vertices are unsolved and white vertices are solved. Then we will put the edge to the parent if it is unsolved. If the parent is solved but not the subtree, after putting an edge the parent will become unsolved and the subtree solved.If the parent is unsolved and the subtree aswell, both will become solved.We can see that the parity of unsolved vertices is always the same, while running this dfs is simply pushing these unsolved vertices up. Then if the black edges are even at the start, we can simply push them all up the root of our spanning tree.
•  » » 4 years ago, # ^ |   +3 There is an answer iff there is a -1 or there is an even number of 1's. You can then get the solution by doing a dfs and just greedily selecting edges you need on your way back up.
•  » » » 4 years ago, # ^ |   0 Can you please elaborate why is there always an answer when d[i]=-1 for some i.
•  » » » » 4 years ago, # ^ |   0 It doesn't matter what degree the -1 node has, so all of it edges can be arbitarily choosed or not choosed. By using this we can fix every adjacent nodes to have correct parity degree, because we can either choose it's edge to the -1 node or not. After that we can make sure the nodes adjacent to the nodes adjacent to the -1 node are good, and so on. Because the graph is connected, we can make every node's degree good.
•  » » » » » 4 years ago, # ^ | ← Rev. 5 →   0 Going by that logic if we satisfy parity of 3 using 1(the -1 node) we get stuck,don't we?4 3-1 0 1 11 21 33 4
•  » » » » » » 4 years ago, # ^ |   0 At the beginning of the algorithm you can replace "-1"-s for necessary values (see my comment below).
•  » » » » » 4 years ago, # ^ |   0 I think the better approach is to calculate the sum of "1"-s and "-1"-s and if we have "-1"-s, to change them for "1"-s or for "1"-s + one "0" depending on the parity of the sum. So we will move to the graph which has "1"-s and "0"-s only.
 » 4 years ago, # |   0 Why does this submission give WA on TC 5 and this submission give AC, when the only difference is the equality sign in the comparator function?I think that the first one should also give AC..
•  » » 4 years ago, # ^ |   0 Compare function must return 0 if they're equal.
•  » » » 4 years ago, # ^ |   0 Why? How does it make a difference?
 » 4 years ago, # |   0 Do you think 1 million number 10e9 can be read with ONLY "cin" in 2 seconds?
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 ios::sync_with_stdio(false); cin.tie(NULL); before reading
•  » » » 4 years ago, # ^ |   0 Yes, I know it. But someone don't write it and still get AC pretest with 1800-2000ms ._. ._.
•  » » » » 4 years ago, # ^ |   0 Maybe they use different compilers?
•  » » » » » 4 years ago, # ^ |   0 I think pretest don't have 1 million number 10e9 :)) it have smaller :))
•  » » » » » » 4 years ago, # ^ |   0 i forgot to use ios_base::sync_with_stdio(false);but i tested my code on local machine with 1000000 10e9 and got 1.53 ms (my machine is way slower then cf machine)
•  » » » » » » » 4 years ago, # ^ |   0 here is the victim http://codeforces.com/contest/841/submission/29559824
 » 4 years ago, # |   +85 WHY
•  » » 4 years ago, # ^ |   0 condolence! I am in the same boat
•  » » 4 years ago, # ^ |   +54
•  » » » 4 years ago, # ^ |   -14 Typically I would be unappreciative of the meme, but I feel it has real value here. Thank you for positively contributing to the Codeforces community!
•  » » 4 years ago, # ^ | ← Rev. 2 →   -8 :(
 » 4 years ago, # |   +12 I got Unexpected verdict on my hack in the solution on problem A and receive this result. What does it mean?
•  » » 4 years ago, # ^ |   +7 Probably someone hacked before you and you didn't reload page to see that. It happened to me in some contests too.
•  » » » 4 years ago, # ^ |   +12 That was not the case.I tried to hack Mr.Donaldo three times using the following testcase: 5 2 aaaaaand then received this verdict.
•  » » » » 4 years ago, # ^ |   +4
•  » » » » » 4 years ago, # ^ |   0 I also had the same problem, at first I got unexpected verdict,but after 30 minutes i tried again and got succesful hack
•  » » » » » 4 years ago, # ^ |   0 I too had the same problem, in fact with the exact same person.
•  » » » » » » 4 years ago, # ^ |   0 Both of your profile pictures also...Dont get me wrong, Mr. Bean is <3
 » 4 years ago, # |   0 How to solve D?
•  » » 4 years ago, # ^ |   0 pick K elements which are different and remove them from the array permanently , keep repeating this process , in the end , we will have atmost K-1 elements left , those are the only possible candidates for our answer , this can be simulated with a segtree easily. Note that K=2 version has appeared before several times.
•  » » » 4 years ago, # ^ |   0 Version with K>2 is also well-known and even appeared in some companies interviews
•  » » 4 years ago, # ^ | ← Rev. 4 →   +55 I think you can just check the frequencies of all the possible candidates for the answer. Sort the subarray. Let sz = (R-L+1)/k. Then the only possible choices are the elements at indices sz+1, 2*sz+1, 3*sz+1... while <= R. Check frequency of each and if any of these satisfy the condition, then that is the answer. Time complexity is O(N*K*logN) Code
•  » » » 4 years ago, # ^ |   0 Elegant solution.
 » 4 years ago, # |   +6 Is there a better solution to D that NlogNKlogK if no , then why is the time limit so strict.
•  » » 4 years ago, # ^ |   +39 There's funny solution to Problem D which it's complexity is O(cnlogn) or O(cn).First, We randomly choose the answer in interval [l, r], then check it.For even k = 5, there's nearly 0.2 probability that we can find it.Assume we randomly choose 90 times, we can deal with each query with correct probability 1 — (0.8)^90 = 0.99999999810286240993581145418021.So for a each testcase, the probability for all the queries are right is 0.99999999810286240993581145418021^{300000} = 0.99943102065261594539434408072871.We need to pass several testcases, assume there're 100 testcases, We can get accepted with probability 0.99943102065261594539434408072871^{100} = 95%.That's our destiny.
•  » » » 4 years ago, # ^ |   +3 i would have definitely submitted this if we had full feedback with all test cases , but with pretests i preferred not to do this.
•  » » » » 4 years ago, # ^ |   0 Sure, I do not have the ability foreseeing the risk
•  » » » 4 years ago, # ^ |   0 How do you solve it in O(c·n). How do you find the frequency of an element in an interval [l, r] in O(1)?
•  » » » » 4 years ago, # ^ |   +5 offline
•  » » » » » 4 years ago, # ^ |   0 How to do this offline?
•  » » » » » » 4 years ago, # ^ | ← Rev. 2 →   0 29579955 UPD:My friend's PRETEST-PASSED submission.(despite getting TLE)
•  » » 4 years ago, # ^ |   0 And you can use some simple technology to reduce the complexity to O(cn). Something like Random for each query at first, then get the answer while inserting the elements to a hash-table.
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 I did with something like sqrt decomposition and it atleast passes in pretest < 500msSet Freq = 300. Max Number of heavy elements having > Freq = 1000Process all queries on heavy elements independently. Elements having freq <= 300 can only be answer where r-l+1 <= 1500. So bruteforce on those light queries.Something like O((N+Q)*1000 + (N + Q)*1500)
•  » » 4 years ago, # ^ | ← Rev. 2 →   +3 Probably to defend straightforward Mo solutions.
•  » » » 4 years ago, # ^ |   0 I couldn't pass with some constant factors. I'd say TL is definitely more strict than it should be.
•  » » 4 years ago, # ^ |   0 It is possible to solve it in time O(NKlogN) using a wavelet tree.
 » 4 years ago, # | ← Rev. 2 →   -15 Interesting questions!! Loved it Dont you get my ironical statement downvoters??
 » 4 years ago, # |   0 Can anyone provide a proof for Div1 C?I got nowhere by trying to analyze the expected value.
 » 4 years ago, # | ← Rev. 2 →   +9 Ok so I almost hacked V--o_o--V's solution for D but I couldn't submit the file because it was too big...later on, I got the answer to my question that I should send the generator...I guess nothing else can be done, now, can it? generally, what sort of syntax should the generator have? I mean does it write the test to standard output? What language should it be written in?
•  » » 4 years ago, # ^ |   +18 You can choose among many languages. Yes, it should print the test to standard output. Once I luckily got 7-th place in Div2 which could have been 5-th if I knew this. I guess we both learnt it the hard way :d
•  » » 4 years ago, # ^ |   0 How to hack his solution? And what's the probability of hacking? :)
•  » » » 4 years ago, # ^ |   0 A test with 60001 of 1 and the other values all distinct that's querying the interval [1, 300.000] 300.000 times would be just enough. The probability for his solution to work on one query is P = 1 — (4/5)^40. The probability for all the queries to work at once is P^300000 ~= 1e-14. It was failing on my machine after less than 20.000 queries usually. So it was sure deal:))The constant that he chose made it easy to hack. On the other side, if it were much larger than that, he'd get TL
•  » » » » 4 years ago, # ^ |   0 I have 80 as constant :DHad pretests passed, not sure about TLE.But seems like it's going to fail as well.
•  » » » » » 4 years ago, # ^ |   +5 On my test, you get 99.4 percent probability of correctness, which is pretty much enough I think. Even if this extreme test were used 100 times in a row, you'll still have a 58 percent chance of getting AC, and for sure there won't be more than 5 or so tests like this one. Also, this test is the worst scenario, so it seems your solution will pass. If they really wanted to make sure it wouldn't pass, they'd have put K <= 8-9 which would destroy any such approach. Honestly, though, I find the randomized approach quite elegant
•  » » » » » » 4 years ago, # ^ |   +5 I had tle on pretests in systesting lol
 » 4 years ago, # |   +39 CF admins, why do you let it happen? 674G - Choosing Ads
•  » » 4 years ago, # ^ | ← Rev. 2 →   -8 Man, now the TL is 2.5 seconds! It's harder!
 » 4 years ago, # |   +34 Am i the only one who solved Div.2 C by just looking at the samples, without understanding what the author wanted???
•  » » 4 years ago, # ^ |   +4 I did that too.
•  » » » 4 years ago, # ^ |   0 Me too :)
 » 4 years ago, # |   +71 Waiting Petr screencast to see myself being hacked. :)
•  » » 4 years ago, # ^ |   +122 Sorry, wasn't recording today :)
•  » » » 4 years ago, # ^ |   +48 :( . I hope you have another chance to hack me.
•  » » » » 4 years ago, # ^ |   0 haha xD
•  » » » 4 years ago, # ^ |   0 What kind of screencast do you provide?:)
 » 4 years ago, # |   -13 Very bad statements (Guys using the Russian statements have an advantage), Long queue at the first 30 mins, Very weird hacking/locking problems bug in my room (not sure about the others).This contest will be unrated right ?
•  » » 4 years ago, # ^ |   0 rated or unrated, I really hate to say this (cause CF really helped me improving a lot) but last few CF contests were really awful and not to forget that there were back to back two unrated contests.
•  » » 4 years ago, # ^ |   +8 Anyway it was understandable, mistakes were grammar mistakes.
•  » » » 4 years ago, # ^ |   +16 Usually I don't complain about grammar if it costs me a few minutes. But today's B took me 45 minutes to understand, and only after backsolving from examples. When variance in read times dominates variance in solve times, then we're measuring the wrong thing.It's not like I didn't try either; I asked very early on for clarification, and got no response.
•  » » » » 4 years ago, # ^ |   0 Yes, you are right. Div2D/Div1B statement was very bad.
•  » » » » » 4 years ago, # ^ |   0 even A
•  » » » » » » 4 years ago, # ^ |   0 and C was modified so many times I opt not to do that. But now I see people just guessed the solutions LOL
 » 4 years ago, # |   +37 Am I the only person that all problems felt too hard? T_T
 » 4 years ago, # | ← Rev. 2 →   0 I was trying to hack @MrSoab B solution with ai=10^9 and n=10^6 it was giving me invalid input why?then I tried with ai=10^7 and n=10^4 and got unsuccesful even though his sum variable should overflow as he declared it as integer
•  » » 4 years ago, # ^ |   0 1) Because you can upload only 256KB input test (maybe) 2) overflow don't mean result is wrong :))
•  » » » 4 years ago, # ^ |   0 Exactly, even if it overflowed the parity was the same, so depending on the language it wouldn't get hacked.
 » 4 years ago, # |   0 Div. 2 C and D were both shots in the dark for me
 » 4 years ago, # |   +8 I guessed a solution for div 2 C based on the examples and it passed the pretests. I sorted A and sorted B in reverse and paired them. But is it actually the solution? How does one prove that this works?
•  » » 4 years ago, # ^ |   0 Prove that if n1 ≥ n2, k1 ≤ k2, then F(n1, k1) + F(n2, k2) ≥ F(n1, k2) + F(n2, k1), so it's always at least as good to assign n1 to k1 and n2 to k2, instead of n1 to k2 and n2 to k1. This means if you sort B in increasing order, you always want to have A sorted in decreasing order, since otherwise you can do better.
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 it works because we have min(A)>=max(B) and we have to maximize the sum of A'[i]-B[i] .
 » 4 years ago, # |   +67 Achievement unlocked : Successfully challenged a randomized solutionhttp://codeforces.com/contest/840/submission/29578088Phew, I pressed the hack button while hoping that I won't be very unlucky.
•  » » 4 years ago, # ^ |   +35 And I pressed the submit button while hoping that I won't be very unlucky :P
•  » » » 4 years ago, # ^ |   +8 That statement seemed so apt for 'L' to say, with that profile picture. :D
 » 4 years ago, # |   0 How to solve Div 2 D ?
•  » » 4 years ago, # ^ |   +8 If it's a tree, the problem is trivial. But it turns out that the extra edges don't have to be used... so just treat the graph as a tree.It's possible if and only if the number of "1" labels is odd. So if there are any "-1" labels, it can always be done (replace all "-1"s with "0"s, except for possibly one "1"). Then do a depth-first search; the edges adjoining the leaves are forced, which forces all the edges all the way up to the root.
•  » » » 4 years ago, # ^ |   0 Can you give me some similar problem to this, which you called trivial? I wanna try to solve that problem
•  » » » » 4 years ago, # ^ |   0 What I meant is the following.Suppose we have a tree (connected graph with no cycles). In this tree, the vertices are labeled 1 and 0; the goal is to choose a subset of "special" edges such that the vertices labeled 0 have an even number of special edges adjoining them, and the vertices labeled 1 have an odd number of special edges adjoining them.This problem is quite straightforward, and once it's solved, it's easy to extend to a generic connected graph (even with multiple edges: it makes no difference).
•  » » » 4 years ago, # ^ |   0 can you explain why the extra edges don't have to be used..
•  » » » » 4 years ago, # ^ |   +11 In a cycle, every node has degree 2. That means that if you remove all cycles from your solution, it will still be correct.
 » 4 years ago, # |   0 Why don't we have different time limits for different languages. Solved C in python , got TLE but same solution in cpp passed. At-least for interpreted languages like python, ruby etc. we should provide 2X time limit.
 » 4 years ago, # |   +10 Div2 e. Kirchhoff's theorem + Gauss method? I just couldn't find matrix determinant.
•  » » 4 years ago, # ^ |   +10 The answer is not determinant of the adjacency matrix, it is the permanent. Computing permanent however, is NP-hard.
 » 4 years ago, # |   +19 The task statements were very bad, but I think that the tasks were still understandable after reading them a few times. It's very annoying and should have been fixed before the contest, but it's really not a reason to make the contest unrated.
•  » » 4 years ago, # ^ |   0 then you might have ended up solving them successfully X_X
 » 4 years ago, # | ← Rev. 2 →   +48 That moment when you don't understand any of the problem statements and manage to solve them successfully. xD
•  » » 4 years ago, # ^ |   +8 Read test and write solution :)) :))
 » 4 years ago, # |   0 How to solve problem E? It gave me a headache!
 » 4 years ago, # |   0 The task 841B How is it possible to have TLE on the pretests for the loop from 0 to 10^6, used to input data anyway, with the task's limit of 2 sec. GNU C++ 11 Thanks.
•  » » 4 years ago, # ^ |   0 Maybe it's an issue with cin/cout being slow? Use ios::sync_with_stdio(0) and cin.tie(0) .
•  » » 4 years ago, # ^ |   0 Or just use scanf/printf instead of cin/cout. I had a friend who had TLE on the same pretest, and just changed cin to scanf and passed.
 » 4 years ago, # |   +14 The Problems' statement was understandable to some degree,maybe was below average this time,but you could understand it.. that's how it was for me, It shouldn't be unrated :D
•  » » 4 years ago, # ^ |   0 Sorry, I didn't understand your comment.
•  » » » 4 years ago, # ^ |   +3 I can see where the problem lies now :)
•  » » 4 years ago, # ^ |   0 I know that in practice, I didn't face such the problem for cin and cout.2 secs and 10^6. This cycle must be finished before 1 sec is expired.
 » 4 years ago, # |   +4 Got TLE on B using simple input , output only Can't understand why???
•  » » 4 years ago, # ^ |   0 mee tooooooo :(
•  » » 4 years ago, # ^ |   0 Apparently, you need to use the IO 'accelerating' lines at the beginning of your main (if using C++): iostream::sync_with_stdio(false); cin.tie(0); `to stay within the time limit
•  » » » 4 years ago, # ^ |   0 Ya , I have Solved the problem using Fastscan() .But i am asking why i m getting TlE even when time limit is 2 SEC
 » 4 years ago, # |   +55 Any hints for Div1 E?
•  » » 4 years ago, # ^ |   +15 Divide all mask into two halfs.
•  » » 4 years ago, # ^ |   +16 Process all numbers within path by blocks of 256. For each bottom vertex of a block and each value of biggest 8 bits of XOR we can precompute the partial answer in 8 * 256: for each number there is a unique value of biggest XOR bits that make 11111111... after XORing (these will obviously be largest answers in their groups), after that traverse a tree from bottom to top and fill still unknown values by swapping smallest bit possible.
•  » » 4 years ago, # ^ |   -49 Hi tourist, some one needs your help !!
 » 4 years ago, # |   +34 How to solve Div1 C? Ok well we can divide the numbers into some equivalent classes.... and so what?
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 --nevermind, this is probably wrong solution
•  » » 4 years ago, # ^ | ← Rev. 2 →   +44 Say you divide the array in groups of sizes X1, X2, ..., Xk. For now, lets consider all of the members of same group identical. In other words label them, and add a constraint that they appear in that fixed order.Then, say there exist xi indices in group, which have next element in the permutation belonging to the same group. Then the number of such orderings is: Now, we can just use inclusion exclusion on the total number of indices where the next element is in same group. Such a term must be multiplied by when added to the total answer.To find the sum over all tuples of xi, we can use polynomial multiplication.In the end, multiply the answer by to account for orderings in same groupI think this could have made a good FFT problem.
•  » » » 4 years ago, # ^ | ← Rev. 2 →   0 If I understand correctly the answer is: but could you clarify how this can be calculated using polynomial multiplication? I can't think of how to separate .
•  » » » » 4 years ago, # ^ | ← Rev. 3 →   +20 Let ,Then the answer is coefficient of xn in So, we can actually solve the problem in instead of O(n3)29575088. This one is O(n2)
•  » » » » » 4 years ago, # ^ |   0 Thank you, that clarified a lot.
•  » » 4 years ago, # ^ |   +8 f(i, oldBad, curBad) = ways to place i, i+1, ..., n-1 if we have placed 0, 1, ... i-1 and there are curBad pairs of consecutive numbers of the same class as i and oldBad pairs of consecutive numbers of the same class, but different of the class of ianswer is in f(0,0,0)I guess you can figure out the base cases and how to do the recursive step :)
•  » » 4 years ago, # ^ |   +58 https://csacademy.com/contest/archive/task/distinct_neighbours then you solve this and you're done. It has an editorial, a really nice dp
•  » » » 4 years ago, # ^ | ← Rev. 4 →   +34 Lol, I opened that problem and it is solved by me. But I didn't manage to solve it again today [facepalm]
•  » » » 4 years ago, # ^ |   0 What is the time complexity of the DP solution described in the editorial? I'm having a hard time trying to figure it out.
•  » » » » 4 years ago, # ^ |