### markysha's blog

By markysha, 8 months ago, translation, ,

Good day to you, Codeforces!

Let me introduce you Codeforces Round #539, that will take place at Saturday, February 16, 2019 at 19:35. The round will be rated for both divisions.

The problems of this round were developed by markysha, xolm, aleex. That is our first round on Codeforces, and I hope not the last one :)

Thanks everyone who helped with tasks preparation:

There will be 6 tasks and 2 hours 30 minutes to solve them. As usual, the score distribution will be revealed shortly before the contest.

Wish you quick ideas and short solutions!

Upd.
Div. 1: 500 — 1250 — 1750 — 1750 — 2250 — 3000
Div. 2: 500 — 1000 — 1500 — 2250 — 2750 — 2750

#### Editorial

Div 1:
1. Um_nik
2. wxhtxdy (was so close...)
3. knightL
4. Swistakk
5. ToTLeS

Div 2:
1. schtomi97
2. Dev0302
3. revivedDevil
4. miseri
5. fragusbot

#### Congratulations to the winners!

Maybe see you later...

• +584

 » 8 months ago, # |   +69 6 days wait is over. :)
 » 8 months ago, # |   -22 hoping for a hell of a contest
•  » » 8 months ago, # ^ |   -32 yeah it will be one atrocity of a contest. this guy has never made a contest before so we can expect the worst...they are just making fun of us at this point
•  » » 8 months ago, # ^ |   0 What hell
 » 8 months ago, # |   +8 How many shared problems between Div. 1 and Div. 2?
•  » » 8 months ago, # ^ | ← Rev. 2 →   -52 I think 4, but it is not certain.
•  » » » 8 months ago, # ^ |   -18 So you think div1A will be div2E? No way.
•  » » » » 8 months ago, # ^ | ← Rev. 4 →   -15 Oh, I mistook. The meaning of the previous comment is "Div1.A = Div2.C", but I momentarily mistook the meaning of shared problem as that of not shared problem.
•  » » » » 8 months ago, # ^ | ← Rev. 3 →   +9 4 shared problems doesn't mean div1A = div2E. 6 problems for each division, with 4 shared problems i.e, Div2A Div2B Div2C = Div1A Div2D = Div1B Div2E = Div1C Div2F = Div1D Div1E Div1F 
•  » » » » » 8 months ago, # ^ |   +23 I posted that before he edited his comment.
•  » » » » » » 8 months ago, # ^ |   +3 Oops! Missed that.
•  » » » » » » » 8 months ago, # ^ | ← Rev. 3 →   +44 Yes. At first I mistook, and (through his comment) after knowing that I edited the commen. But I had to accept the downvote due to the mistake. Maybe it was and is a good experience...
•  » » » » » » » » 8 months ago, # ^ |   +3 That's why people despise the 'codeforces community' , as they given 100's of down-vote(s) to guys who might have done a very small mistake even without knowing . You guys should not spread your frustration and negativity to others :-) (to the down-voters)
 » 8 months ago, # |   +3 "(yeah, we approached testing thoroughly :))" This is important. I hope this is true.
•  » » 8 months ago, # ^ |   0 I also hope)
 » 8 months ago, # |   +1 congratulations on your first contest.
 » 8 months ago, # | ← Rev. 2 →   -29 Is there a separate contest for both divisions or combined for both divisions?
•  » » 8 months ago, # ^ |   +9 SeparateThere is actually a link in the post.
 » 8 months ago, # |   -59 do you even care about us anymore? the last few contests were like bad jokes full of math and other useless stuff. what happened? why did we stop getting good contests? are we not worthy anymore? do we not matter for you anymore? you just wanted us to make the statistics and now you shit on us?
•  » » » 8 months ago, # ^ |   -8 the truth hurts and that’s why people are downvoting. they know what i’m saying is true and are mad so they are downvoting me to make them feel better
 » 8 months ago, # |   -156 make good contest or die
 » 8 months ago, # |   +23 Hope this will be a fun and well-made round.Good luck to all participants!
 » 8 months ago, # |   -36 do you even care about us anymore? the last few contests were like bad jokes full of math and other useless stuff. what happened? why did we stop getting good contests? are we not worthy anymore? do we not matter for you anymore? you just wanted us to make the statistics and now you shit on us?
 » 8 months ago, # |   +6 Finally I can have my chance to participate (I attempted to evade 2 previous rated contests to preserve the color formation) :DGuess now would be my perfect chance to do good (or maybe do bad and reach purple, who knows :P)
•  » » 8 months ago, # ^ |   +7 Good luck!
•  » » 8 months ago, # ^ |   0 I am really sorry, that your preserved color is gonna fade away :|
•  » » » 8 months ago, # ^ |   +1 Somehow I predicted this to be happening... :<
 » 8 months ago, # |   +12 Congratulations on your first contest! Will this round feature any interactive problem?
 » 8 months ago, # |   -58 Score: 500-750-1000-1500-1750-2000P.S. It is just my opinion, and what about you?
 » 8 months ago, # |   +28 NO GreenGrape xD.
 » 8 months ago, # |   +12 If the site does not collapse i think it will be a good round. I wish good luck to everyone!
 » 8 months ago, # |   +4 Make good contest and hope no 404Error or sitedown issues.
•  » » 8 months ago, # ^ |   0 Oh,404Error......
 » 8 months ago, # | ← Rev. 2 →   +11 Please ensure that the pretests are strong. There has been a spate of weak pretests in recent contests.
•  » » 8 months ago, # ^ |   +32 Hacks are part of codeforces contests
•  » » » 8 months ago, # ^ |   -32 it will be rigged as always
•  » » » » 8 months ago, # ^ |   +6 be more optimistic :)
•  » » » » » 8 months ago, # ^ |   -31 about what? all odds are against us. newbie contest maker (it’s his first ever) so we can expect the worst and they are treating us miserably. there really isn’t anything to be optimistic about.
•  » » » » » » 8 months ago, # ^ |   +14 All the authors have a great life experience in making contests, so please think twice before saying something.
•  » » » » » » » 8 months ago, # ^ |   -31 please think twice before posting a contest
•  » » » » » » » 8 months ago, # ^ |   0 please think twice before posting a contest.
•  » » 8 months ago, # ^ | ← Rev. 2 →   +10 There has been a spate of weak pretests in recent contests.Hmm, no, have you been too obsessed with CodeCrafts?AFAIK two most recent contests are fine.jinlifu's round is a pretty good round ruined only by server issues.And about my contest, please research closer (all following data is calculated during contest time): Spoiler 277 FSTs + 9 hacks for A out of 6243 "pretest passed" (~4.58% fail rate). 487 FSTs + 0 hacks for B out of 2963 "pretest passed" (~16.4% fail rate). 88 FSTs + 0 hacks for C out of 1984 "pretest passed" (~4.44% fail rate). 0 FSTs + 0 hacks for D out of 807 "pretest passed" (~0% fail rate). 42 FSTs + 16 hacks for E out of 361 "pretest passed" (~16.1% fail rate). 3 FSTs + 0 hacks for F out of 78 "pretest passed" (~3.85% fail rate). B might be a little weak of compared to the other (yet oddly not even a hack was made), and E's random nature makes hacking it inevitable. Still, the fail ratio is still not even one-sixth yet.
•  » » » 8 months ago, # ^ |   0 I was talking mainly about round 537(codecraft). I apologize if it sounded accusatory or was worded badly.
•  » » » » 8 months ago, # ^ |   0 "recent contests" sounds like you're summing things up.Be specific, and optimistic. ;)
 » 8 months ago, # |   +10 i am with a hope to cross rating 1200
 » 8 months ago, # |   -38 wow~ any interact problem?
•  » » 8 months ago, # ^ |   -8 No, we would say if there was an interactive problem
•  » » » 8 months ago, # ^ |   +29 Any clue when this will stop? I hope we eventually get to a point where interactive problems are just treated like normal problems.
 » 8 months ago, # |   -18 Kindly make time period 2 hours and make problems accordingly tough. 2:30 is much longer. (At least for Div 2).
 » 8 months ago, # | ← Rev. 2 →   -9 Good luck to everyone.
•  » » 8 months ago, # ^ |   -31 really no one cares
 » 8 months ago, # |   +2 Congratulations on your first contest..love to see div2 contest
 » 8 months ago, # |   +5 I wish everyone high rates!
 » 8 months ago, # |   -26 Is it rated?xD.. hopefully so because my first contest.. wish you all good luck
•  » » 8 months ago, # ^ | ← Rev. 2 →   -28 ­.
 » 8 months ago, # |   -12 Why the downvote on me comment? I say good luck to all.. !!
•  » » 8 months ago, # ^ |   +11 It is better to refrain from containing "Is it rated?" in the comment.
 » 8 months ago, # |   -18 A bad time for Chinese players :(
•  » » 8 months ago, # ^ |   +33 It's always a bad time for someone, quit whining.
 » 8 months ago, # |   0 Best of luck every one.
 » 8 months ago, # |   +21 It's my first div1 contest...A bit nervous...Anyway,good luck to you all.
•  » » 8 months ago, # ^ |   +11 I had that feeling too in my first Div. 1 round, luckly things ended up great and I solved 2 problems earning +76 :DGood luck
•  » » 8 months ago, # ^ | ← Rev. 2 →   +5 I'm in the same boat (@1904). I'm both nervous and excited! Good Luck!
 » 8 months ago, # |   -47 is it rateed?
•  » » 8 months ago, # ^ |   +1 The round will be rated for both divisions.
•  » » 8 months ago, # ^ |   -23 Are you gay?
•  » » » 8 months ago, # ^ |   0 People are free to choose their sexuality.
 » 8 months ago, # | ← Rev. 7 →   0 The problem:A in Div.1 will be which problem in Div.2 ?C or D
 » 8 months ago, # |   0 Hope short and clear statements...
 » 8 months ago, # | ← Rev. 2 →   0 Best Of luck everyone
•  » » 8 months ago, # ^ |   0 Best of luck to you also
 » 8 months ago, # |   +2 So far there are no registrants with rating 2019...???
 » 8 months ago, # |   +11 yay — a contest that california people can take! good luck everyone!
 » 8 months ago, # |   0 Hello and Good Luck all of them
 » 8 months ago, # |   0 bad timing for chinese... im sleeping during that time...
•  » » 8 months ago, # ^ |   +16 How can sleeping time be bad ?
 » 8 months ago, # |   +4 Finally! Indians can have their dinner and give the test
 » 8 months ago, # |   +1 Good luck!
 » 8 months ago, # |   0 Finally contest comes after 6 days
 » 8 months ago, # |   0 Good Luck
 » 8 months ago, # |   +1 I can't submit. When I click submit the "You have submitted exactly the same code before" notification appears, also I can't ask questions :/
 » 8 months ago, # |   0 Wtf is wrong with pretest 7 on Div2.B?????
•  » » 8 months ago, # ^ |   0 same shit
•  » » 8 months ago, # ^ |   0 try: 2 100 1. should give you 20.
•  » » 8 months ago, # ^ |   0 Atmost 1 operation can be performed by the farmer. Trying to perform more than one operation results in failure in this test.
 » 8 months ago, # |   -10 a xor b xor c means ((a xor b) xor c) ?
•  » » 8 months ago, # ^ |   -8 There's no matter in how you place the brackets
 » 8 months ago, # |   +41
•  » » 8 months ago, # ^ |   +110 Does someone have to post this every time?
•  » » » 8 months ago, # ^ |   +29 You stole my up-votes xD
•  » » 8 months ago, # ^ |   +3 What the hell "@yourfavoriteexgf" is doing in that image??
 » 8 months ago, # |   0 In Problem C Div2 what are l and r?
•  » » 8 months ago, # ^ |   0 The boundaries of the range described
 » 8 months ago, # |   +5 Very nice contest, was eagerly waiting for it...
 » 8 months ago, # |   0 Was there at all a successful hack today?
•  » » 8 months ago, # ^ |   0 I saw a person with +3:-2.
•  » » » 8 months ago, # ^ |   0 Oh okay thanks.But all I could find was -1 or -2 hack counts.
•  » » 8 months ago, # ^ | ← Rev. 2 →   +6 You can always go to the contest->status and use status filter to see all successful hacks in the contest. Image
•  » » » 8 months ago, # ^ |   0 Wow, thanks alot. This is something I never knew that it existed even after 2 yrs of cf.
 » 8 months ago, # |   0 whats wrong with protest 7 (problem B)
•  » » 8 months ago, # ^ |   +11 Your solution might have a bug.
 » 8 months ago, # |   0 how to solve c? my code TLE testcase #9 T^T
•  » » 8 months ago, # ^ |   +1 tle in 11 worst case takes around 3 seconds tried every optimization :(
•  » » 8 months ago, # ^ |   +8 Though I didn't participated but I think dividing prefix xors for even and odd indexes should work
•  » » » 8 months ago, # ^ | ← Rev. 2 →   -6 my idea is xor(l~r) = xor(xor(mid~r),xor(l~mid)), but i didnt optimize to find this for every array..
•  » » 8 months ago, # ^ |   0 This might help:Let's say you have numbers A and B. C = A XOR B Then C XOR B will be A. You can use this in ranges too
•  » » 8 months ago, # ^ | ← Rev. 2 →   0 Let's consider segment (l, r] where r-l is odd, then p[r] xor p[(l+r)/2] = p[(l + r)/2] xor p[l] p[r] = p[l] Now it's simple thing to calc.
 » 8 months ago, # |   +4 How to solve div2 Problem C?
•  » » 8 months ago, # ^ |   +4 Maintain prefix XOR. Partition the indices with two of them in the same set if their prefix XORs are same. Maintain separate count for odd and even indices in each of the partitions. Answer will be the sum over all partitions of (odd choose 2) + (even choose 2).
•  » » 8 months ago, # ^ | ← Rev. 2 →   +5 First, note that the problem can be reduced to count number of subarrays given xor by noticing thata[i] ^ a[i+1] == a[i+2] ^ a[i+3] equals to a[i]^a[i+1]^a[i+2]^a[i+3] with zero as a result.Hence, given xor will be 0.Since the problem limits to even-size array only, we need to modify the array a bit. We can try to merge every index i and i+1 (i.e. a[1]..a[n] becomes {a[1]^a[2], a[3]^a[4], ... } Then the problem simply becomes count number of subarrays given xor.But, another caveat is that we only handle even indices. We also need to create an array consisting of {a[2]^a[3], a[4]^a[5], ... } to handle odd indices.P.S. You can simply google how to count number of subarray given xor
•  » » » 8 months ago, # ^ |   -14 I think there is a problem with finding number of sub arrays with xor 0.a[i] ^ a[i+1] == a[i+2] ^ a[i+3] equals to a[i]^a[i+1]^a[i+2]^a[i+3] with zero as a result  The converse isn't true for this statement, i.e., if xor from range [l, r] is 0, that doesn't mean we can partition it such that xor from range [l, mid] = xor from range [mid + 1, r]
•  » » » » 8 months ago, # ^ |   0 Can you give an example?
•  » » » » » 8 months ago, # ^ |   0 Yes you are right. I made a mistake. If the xors of left range and right range were a and b, where a not equal to b, then a xor b can never be zero.
•  » » » » 8 months ago, # ^ | ← Rev. 2 →   -8 Ignore my original comment, I was stupid :<
•  » » » » » 8 months ago, # ^ |   0 Are you sure? Can you provide contrary instance for second?
•  » » » » » 8 months ago, # ^ |   0 It is always true. Do you have an example when it's not?
•  » » » » » 8 months ago, # ^ |   0 Oops, I was going full mad. Sorry guys :<
 » 8 months ago, # | ← Rev. 3 →   +7 How to solve div2 D ? sashan and one more name ? Any idea . btw good contest , div2 a was also a little bit thinking .
 » 8 months ago, # |   0 how to solve Div 2 C
 » 8 months ago, # |   +3 How to solve Div2 D?
•  » » 8 months ago, # ^ |   +10 Hint : Answer belongs to {1, 2, Impossible}
•  » » 8 months ago, # ^ | ← Rev. 3 →   +1 Assuming my solution works:You can split the problem into two cases, a palindrome of odd length and even length. For both cases, you can notice that the answer will either be 1 or two. That's a major hint.For odd cases: Checking for the "Impossible" case isn't too difficult so I won't explain that. The answer will always be 2 for this case otherwise (we can cut a prefix and a suffix of the string a "swap"). For even cases: If both halves aren't palindromes, the answer is 1. Else, we can check if we can cut some prefix and append it to the back to form a palindrome that is different from the original one (if yes, the answer is 1). Otherwise, the answer is 2 by the same reasoning as the odd case.
•  » » 8 months ago, # ^ | ← Rev. 3 →   +4 Div2D: Solutions fall into 3 cases: {1,2,impossible}.Let's think of a palindrome as consisting of "mirrored" part and a possible "center" character. For example, "abcxcba" has "x" center and "abc" mirrored part.Impossible case: input where the mirrored part consists of only 1 character. For example, "qq" or "qqqxqqq". If the mirrored part consists of more than 1 character, for example, "abcxcba", then we can always solve with 2 cuts (cut the outermost 2 characters from both sides in the example).So if the answer is not impossible we just need to check if a 1-cut solution is possible. If it's not, the answer is 2. Since input length is only 5000, we can try all possible places for 1 cut, check that we get a palindrome, and that the palindrome is different than the original palindrome.
 » 8 months ago, # |   +26 What is so specific to test 9 in div1C? It's killed me...Also I really don't get why C. The other problems seemed decent, but this one is just coding. D was nice, E was very DSish (I'd personally rather find its place in an educational round). Didn't have time to read F. I absolutely loved B.
•  » » 8 months ago, # ^ |   0 Can you explain D?
•  » » » 8 months ago, # ^ |   +24 It's pretty mathy: you have to know prufer codes. Basically you can infer the following thing: the number of trees on N nodes with given degrees d1, d2, .., dN is the multinomial coefficient on the array d(i)-1, that is: (N-2)!/product of (d(i)-1)!. That comes from the number of arrays of length N — 2 where i appears exactly d(i)-1 times. It's easy to prove that once you know the bijection between the prufer codes and the labelled trees. Now, assume you've fixed the distance between the 2 nodes to be K (note the actual 2 nodes don't matter and you can ignore them, I for one, haven't read them). That implies you should have K — 1 ordered nodes on the path between them. There are (N-2)(N-3)...(N-(K-1)+1) ways of doing so. Then, let's assign their weights: the number of ways of writing M as sum of K numbers: C(M-1, K-1). Then the rest of the weights are free to take any value: M^(N-2-K). Now we're interested in the actual number of trees. Let's contract the K+1 nodes on the path into one big node. The thing is that you now care about the degree of that big node. Assuming it is d, you have to multiply the answer by (K+1)^d because for every node that has chosen it to be a neighbor, you need to assign an actual concrete node out of the K+1 small nodes that make up the big node. So if you iterate d, then you can choose the d-1 spots where the id of the big node will be placed and complete the rest of them with anything. This is N^2. The inner loop (the one that iterates d) can be algebraically manipulated to look like a constant times a sum of C3*C(C1, i)*C2^i which gives C3*(C2+1)^C1 where C1 and C2 are some constants that you can find by grouping together things that are dependent on d and things that are not. You then get NlogVmax because of some raisings to power (that I think you can skip if you really want to, but there's no need for that).
•  » » » » 8 months ago, # ^ |   0 Thanx a lot!!Can you please suggest any tutorial for prufer codes and some related problems?
•  » » 8 months ago, # ^ |   +16 You should not take into consideration events that appeared before l. In other words, the initial s on the interval should be 0, not the last speed that was set before l. Such a fix changed my score from "Wrong Answer on test 9" to "Pretests Passed".
•  » » » 8 months ago, # ^ |   +24 Fuck...Thanks for telling me. Now I can die peacefully
 » 8 months ago, # |   +4 Very good and balanced contest! Thanks to writers.
 » 8 months ago, # |   +14 How to solve div1 D?
•  » » 8 months ago, # ^ | ← Rev. 2 →   +35 https://en.wikipedia.org/wiki/Cayley%27s_formula #generalizationsThen you just enumerate the number of points between A and BKnowing how to google properly gives 1750 in div1! How motivational
•  » » » 8 months ago, # ^ |   0 do we need to know the above theorem to solve it . if yes , it must be pretty hard for them who have no idea abt. cayles theroem
•  » » » » 8 months ago, # ^ |   +9 you can derive it by https://en.wikipedia.org/wiki/Pr%C3%BCfer_sequence , which seems intuitive enough, i guess
•  » » » 8 months ago, # ^ | ← Rev. 2 →   +5 There is a very interesting question still remains: how to find a number of different paths with length i and sum m?UPD: sorry for the stupid question, it was just Cnk :)
•  » » » » 8 months ago, # ^ |   0 You can use stars and bars method
•  » » » 8 months ago, # ^ |   +8 Found the formula, thought it was useless, skipped XD
•  » » » 8 months ago, # ^ |   0 Also, there is no such a generalization in the russian version of the wiki page. I'll take a note about always reading English version.
•  » » » 8 months ago, # ^ |   +10 Sadly, I didn't give too much attention to the generalization section due to the round pressure.So, in the end, I spent some upsolving hours creating my own generalization based on the specific Cayley's formula proof by double counting (https://en.wikipedia.org/wiki/Double_counting_(proof_technique))But, afterwards, it was rewarding for me to see that it was a relevant result.
•  » » 8 months ago, # ^ |   0 Use cayley's and basic combinatorics to find the number of trees in which we have k edges in simple path from a to b. (a, b doesn't actually matter)
•  » » 8 months ago, # ^ |   +8 let's renumerate vertices a = n — 1, b = n. Than think about Prufer Code. You'll have path between n — 1 to n with number of edges >= e if Prufer code ends with (e — 1) sequence of distinct numbers that are less than n — 1. Than you can find formulas for dp[e] (it's just what is written above) to make number of edges == e just subtract from dp[e] , dp[e + 1] and dp[e + 2] ... Implementation for details 50017868
•  » » 8 months ago, # ^ |   +21 Sad thing is I looked at that page but skipped past the formula. Sad face!
•  » » » 8 months ago, # ^ |   0 lol : ans = wiki .. haha
 » 8 months ago, # |   +1 Nice problemset, especially 1B and 1D ;) (though I failed both miserably :D)
•  » » 8 months ago, # ^ |   0 how u solved div1 b ?
•  » » » 8 months ago, # ^ |   0 A little bit intuitive (I didn't make it to prove just yet), but the answer can only be either 1, 2 or Impossible. Thus, this can be solved by some bruteforce.
•  » » » » 8 months ago, # ^ |   0 in the recent cf rounds , i m solving problems upto c but i have very little of no proof for it . just a gut feeling and implement it . it passes .
•  » » » » 8 months ago, # ^ |   +8 Well, I think you can prove it by showing that if you swap a prefix of s with a suffix of s such that the prefix/suffix is not a palindrome, then it will be sufficient. Because of this, as long as the n/2 prefix and n/2 suffix are not all the same letter, it is possible in 2 moves or less. Then you can brute force to check 1 move solutions.
•  » » » » » 8 months ago, # ^ |   0 thanks .
 » 8 months ago, # | ← Rev. 2 →   +10 Problems were very interesting to solve. Thanks for your first contest! :)
 » 8 months ago, # |   +15 It took me nearly an hour to realize that if a_l ^ a_l+1 ^ ... ^ a_r = 0 then a_l ^ a_l+1 ^ ... ^ a_x alway equals a_x+1 ^ a_x+2 ^ ... ^ a_r
 » 8 months ago, # |   0 thinking in C dp gave me headache but it was a nice problem
 » 8 months ago, # |   0 Can someone pls tell what is wrong with this code? https://codeforces.com/contest/1113/submission/50033374
•  » » 8 months ago, # ^ |   0 i dont know if this is helpful, but testing your code against: 2 1 100. gives me 100 instead of 20.probably you're missing the fact that your meant to perform the increase & decrease at most once.
•  » » » 8 months ago, # ^ |   0 It's giving 20. Can u pls check again?
•  » » » » 8 months ago, # ^ |   0 sorry my mistake. try 2 100 1. should give 20. but gives 101.
•  » » 8 months ago, # ^ |   0 forn(i,0,n) { cin>>a[i]; ... forn(i,1,n) { ... second for is from 1
•  » » » 8 months ago, # ^ |   0 Ok got it.My bad.
 » 8 months ago, # |   0 Is Div2E/Div1C solved by doing minimum-prefix-sum query with segment tree?
 » 8 months ago, # |   +64 Nice problems! The round was quite hard but it isn't a bad thing, I guess.
•  » » 8 months ago, # ^ |   0 for div1d , have u used cayles theorm ?
•  » » » 8 months ago, # ^ |   +1 I described my solution under the editorial: https://codeforces.com/blog/entry/65295?#comment-492971.
 » 8 months ago, # |   0 Can anyone please tell me what's wrong with this code: https://codeforces.com/contest/1113/submission/50029202
•  » » 8 months ago, # ^ |   0 #define read(a,n) upto(i,0,n-1,1) cin>>a[i]; ... for (int i = n-1;i>=1;i--) ... for to 1 instead of 0
•  » » » 8 months ago, # ^ |   0 its sorted so you don't have to consider first element...because i am multiplying factor with arr[0] every time.
•  » » » » 8 months ago, # ^ | ← Rev. 2 →   0 #define MAX ((int)1e4 + 1) should be 5e4 + 1 :/
•  » » » » » 8 months ago, # ^ |   0 silly mistake:( thanks for pointing it out...
•  » » » » » » 8 months ago, # ^ |   0 yea, it's the worst :C
 » 8 months ago, # |   0 In 1B, I completely missed that the initial string was a palindrome, I was trying to solve for general string(as constraints were bit low), after struggling for 30 mins I re-read the problem.
 » 8 months ago, # | ← Rev. 3 →   0 -
•  » » 8 months ago, # ^ |   0 What will you do when all numbers are odd?
•  » » » 8 months ago, # ^ | ← Rev. 2 →   0 -
•  » » 8 months ago, # ^ |   0 What about this one?51 3 5 7 64Optimal X = 8, operated on 64
•  » » » 8 months ago, # ^ | ← Rev. 2 →   0 -
 » 8 months ago, # | ← Rev. 2 →   -12 Can anyone tell me why this DIV2B code is WA?  Spoiler#include using namespace std;int ada[101]; int a[500005];int main(){ memset(ada,0,sizeof(ada)); memset(a,0,sizeof(a)); int n; cin>>n; int sum = 0; for(int i = 0; i < n; i++){ cin>>a[i]; sum += a[i]; ++ada[a[i]]; } int msum = sum; int temp = 0; for(int i = 0; i< n; i++){ for(int j = 2; j*j <= a[i]; j++){ temp = msum; if(a[i]%j == 0){ int c = a[i]/j; int b = j; if(ada[j]){ temp -= a[i]+b; temp += a[i]/b + b*b; sum = min(sum,temp); } if(ada[a[i]/j]){ swap(c,b); temp = msum-(a[i]+b); temp += a[i]/b + b*b; sum = min(sum,temp); } if(ada[1]){ c = a[i]/j; b = j; temp = msum-(1+a[i]); temp += c+b; sum = min(sum,temp); } } } } cout<
•  » » 8 months ago, # ^ |   0 check for: 2 1 100 Answer should be 20
•  » » 8 months ago, # ^ |   0 4 7 5 8 3 answer is 22, your program is giving 23
•  » » 8 months ago, # ^ | ← Rev. 2 →   +4 Next time you want to put some code in comments, I suggest you using pastebin, ideone, link to your submission or even the thing called "spoiler", because it's not very nice to put your long code in the comments section)
•  » » » 8 months ago, # ^ |   0 noted, thanks!
•  » » 8 months ago, # ^ |   0 Use a spoiler tag. A long code comment makes it difficult to read all the blog comments. Especially on mobile.
 » 8 months ago, # |   0 clashroyale & dragn78 .. 1 user, 1 room, 2 accounts.
 » 8 months ago, # |   +54
 » 8 months ago, # |   +8 Why the system testing hasn't started yet?
•  » » 8 months ago, # ^ |   +3 Probably there is some dispute about tasks.
 » 8 months ago, # |   +25 Oh I almost got Div.1 D, I was just having some bugs and didn't get it on time.Amazing problem-set, enjoyed every minute in the round
 » 8 months ago, # |   +1 Damnnn!!! Completely missed that initial string is palindrome in Div2-D. fml.
•  » » 8 months ago, # ^ |   0 Me too :(
 » 8 months ago, # |   +5 For more contests on the weekends : )
 » 8 months ago, # |   +18 MikeMirzayanov I think this should be considered as cheating. look hereThe person who has done this 6-vkcom-stupidjokesproga
•  » » 8 months ago, # ^ |   0 This is hilarious. What are the odds that his alt account and him were assigned to the same room.
•  » » » 8 months ago, # ^ |   0 I think that he has many alts, so it is more likely to get in the same room as one of his alts.
•  » » » » 8 months ago, # ^ |   +21 Birthday paradox at work.
•  » » » » » 8 months ago, # ^ |   +6 Only if he's willing to get rating on any of the accounts. It's much more likely that he has one main account and multiple helpers and then birthday paradox doesn't apply.
 » 8 months ago, # |   +5 The contest with least Hacks and System Test Fails !
 » 8 months ago, # | ← Rev. 2 →   -22 div2-C I think the question is ambiguous.
•  » » 8 months ago, # ^ |   0 That's why they are giving that specific sample.
•  » » » 8 months ago, # ^ |   0 Okay，I think what you said is reasonable.
 » 8 months ago, # | ← Rev. 2 →   +8 good contest. :)
 » 8 months ago, # |   +104 road to yellow
•  » » 8 months ago, # ^ |   +27 Fairly
•  » » 8 months ago, # ^ |   +48 Follow my lead
•  » » 8 months ago, # ^ |   +31 Well, that's actually an aim for some people :)
 » 8 months ago, # | ← Rev. 2 →   +10 It seems that systests for problem Div1C don't contain test with query similar to3 1 1 0I resubmitted my solution, because found that my first version printed '-1' on this test, but it should print '1'. After contest I submitted first version and it got AC too.
•  » » 8 months ago, # ^ |   0 For what question?
•  » » » 8 months ago, # ^ |   0 I think he is talking about div1C
•  » » » » 8 months ago, # ^ | ← Rev. 2 →   0 Oops I was wrong..
•  » » » » 8 months ago, # ^ |   0 Yeah, it was about div1C, i missed it >_<
 » 8 months ago, # | ← Rev. 2 →   0 Can anybody tell me why my 1st solution for div2D is giving wa on 8 but when I changed the code a little bit with even less memory it is giving MLE on test case 1. MLE solutionWA on 8 solution
•  » » 8 months ago, # ^ |   0 It seems you did more than one change. Inside main there are two nested loops and an unused variable g in the WA8 code. Then you used it in the MLE solution. I've taken your MLE code without using said g variable and it uses less memory but still WA8. I guess you did some logic corrections wich ended in MLE, maybe you didn't set properly the values in P matrix, what do you think?