By pikmike, history, 21 month(s) ago, translation,

Hello Codeforces!

Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.

This round will be rated for the participants with rating lower than 2100. It will be held on extented ACM ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 7 problems and 2 hours to solve them.

The problems were invented and prepared by Roman Ajosteen Glazov, Adilbek adedalic Dalabaev, Vladimir Vovuh Petrov, Ivan BledDest Androsov, Soroush Tabesh Soroush.T and me.

Good luck to all participants!

Congratulations to the winners:

Rank Competitor Problems Solved Penalty
1 chuochuo 7 222
2 Traxex_ 7 270
3 quailty 7 281
4 hitman623 7 285
5 E.Space 7 316

69 successful hacks and 296 unsuccessful hacks were made in total! The table doesn't look that interesting this time, so I won't include it.

And finally people who were the first to solve each problem:

Problem Competitor Penalty
A irkstepanov 0:00
B ChiIIi 0:03
C Qing_Yang 0:06
D aleex 0:07
E chuochuo 0:57
F isaf27 0:19
G 300iq 0:06

UPD: Editorial is out

• +148

 » 21 month(s) ago, # | ← Rev. 2 →   -6 ggguys i cant wait! !=) X) :)
 » 21 month(s) ago, # |   -13 what is this and is it contributed??
•  » » 21 month(s) ago, # ^ | ← Rev. 2 →   -15 sorry i cant read
 » 21 month(s) ago, # |   0 Second last chance to reach my 2018 rating goals lol.
 » 21 month(s) ago, # |   -36 hello gays i live in a very wealthy part of the austro hungarian empire and i am wondering if the contest will be worthy of my royal time i request you inform my intelligence on whether the contest will be rated or not
•  » » 21 month(s) ago, # ^ | ← Rev. 2 →   0 you can read the first line it cleary says that is rated for div2 participants/
•  » » » 21 month(s) ago, # ^ |   -21 sorry i cant read
•  » » 21 month(s) ago, # ^ |   -7 king_tsar Is this you? lol
•  » » » 21 month(s) ago, # ^ |   0 looks more or less like me :)
 » 21 month(s) ago, # |   0 However,I love Educational round.
 » 21 month(s) ago, # |   0 YESSS...a div2 round for candidates ;)
 » 21 month(s) ago, # |   0 The last educational rounds in this year.... :')
 » 21 month(s) ago, # |   0 I hope it would be a great educational
 » 21 month(s) ago, # | ← Rev. 2 →   -10 Hope I can become hahalmao555huehuekkkxixi after the contest.
 » 21 month(s) ago, # |   0 Today I'll become a Christmas mandarin orange.
•  » » 21 month(s) ago, # ^ |   +5 Good luck! :)
 » 21 month(s) ago, # | ← Rev. 2 →   0 When can we change Nickname?
•  » » 21 month(s) ago, # ^ |   +18 when you learn grammar!
•  » » » 21 month(s) ago, # ^ |   -13 It is "when will you learn grammar!"
•  » » » » 21 month(s) ago, # ^ |   +3 No that requires a question mark
•  » » » » » 21 month(s) ago, # ^ |   +3 XD
•  » » » » » 21 month(s) ago, # ^ |   0 you are braindead
 » 21 month(s) ago, # |   +42 One interesting thing in this contest is that both the description and problem name of problem G greatly resembles Problem D in XVIII Open Cup, GP of Urals. But the solution differs a lot, and actually, the solution to that Open Cup problem is more similar to Problem E of this contest. That's why I think the problem difficulty of E,F and G in this contest should be rearranged, with G being extremely trivial once you know FFT, F being some simple calculation once you know the linearity of expectation, and E needs some combinatorics knowledge(like counting in a multiset and inclusion-exclusion principle). And the number of accepted solutions seems to prove me right.
 » 21 month(s) ago, # |   +14 Problem F reduces (at least I reduced) to calculating this sum in small complexity: for given x, y, m.Any hints to calculate this?
•  » » 21 month(s) ago, # ^ |   +20 LOL, LMAO, ROFL. No, it's not solved like that.Normal solution: there are three kinds of inversions: Inversions between known elements — they are calculated by your favourite method (Fenwick / mergesort) Inversions between unknown elements — if there are P unknown elements, they form P*(P-1)/4 inversions due to symmetry The last case is when one element is known, and the other is unknown. Let the known element be x, and there are some free places to the left and some free places to the right. For each of free left places, there is an inversion if you put element > x there (find count of these elements by lower_bound). For each of free right places, there is an inversion if you put element < x there (find count of these elements by lower_bound). And the rest is easy.
•  » » » 21 month(s) ago, # ^ |   +38 LOL, LMAO, ROFL. No, it's not answered like that.My question is about calculating the sum not how to solve the problem. Anyways, thanks for the solution :P
•  » » » » 21 month(s) ago, # ^ |   0 This is a valid method of calculating the sum in reasonable complexity though, given that it reduces to the same thing (differing by some easy-to-calculate value). You're just counting the same thing in different ways and equating them.
•  » » » » 21 month(s) ago, # ^ | ← Rev. 2 →   0 I think you have already figured out how to solve this problem, my reply is too late. :P I was trapped in the same calculation as you. However, after peeking others' solutions, I found it better to calculate the expectation alone, rather than calculate P and Q separately. This problem enlightened me a new angle to calculate expectations. When it is the case that P is hard to calculate, we may try to calculate the expectation directly. Good luck!
•  » » 21 month(s) ago, # ^ |   0 First idea and very overkill is next: let and , then your sum is coefficient of zm of a convolution A × B or something like this (if you calculating with modules). Convolution FFT.
•  » » » 21 month(s) ago, # ^ |   +29 If you write A and B in closed form as follows:A = x·z·(1 + z)x - 1B = (1 + z)yand then multiply them, then coefficient of zm in A × B = x·z·(1 + z)x + y - 1 would be simply x·C(x + y - 1, m - 1).
•  » » 21 month(s) ago, # ^ |   0 Does anyone know why my nlogn solution is timing out?https://codeforces.com/contest/1096/submission/47665224
•  » » » 21 month(s) ago, # ^ |   0 It might be because my distance is linear...but I also tried with Fenwick tree, and still.timeout
 » 21 month(s) ago, # | ← Rev. 2 →   +20 It's guaranteed that rating of this topic will never exceed 998244353 (by absolute value).(OK, it's not really)
 » 21 month(s) ago, # |   +18 number 998244353 everywhere
 » 21 month(s) ago, # |   0 How to solve G? Is it some sort of bruteforce on small strings + DP? Couldn't figure out the details in time.
•  » » 21 month(s) ago, # ^ |   +50 Trivial when you know how to accelerate polynomial multiplication using Fast Fourier Transform.
•  » » » 21 month(s) ago, # ^ |   0 Can you elaborate a bit? Specifically, what are the polynomials you're building and then multiplying? Thanks!
•  » » » » 21 month(s) ago, # ^ |   +6 Let polynomial f(x) = a0 + a1x + ... + a9x9, where ai = 1 if i is an available digit and 0 otherwise. Then the answer is sum over the square of every term of f(x)n / 2.
•  » » » » » 21 month(s) ago, # ^ |   0 Ah, yeah, that's really obvious once pointed out. Thanks again!
•  » » » » » 21 month(s) ago, # ^ |   0 Finally someone wrote a answer that can be understood by every one...Thanks a lot chuochuo
 » 21 month(s) ago, # |   +10
•  » » 21 month(s) ago, # ^ |   -30 F is easier than D
 » 21 month(s) ago, # |   0 How to solve B?
•  » » 21 month(s) ago, # ^ | ← Rev. 2 →   0 +1, I got that wrong too. Help please.
•  » » 21 month(s) ago, # ^ | ← Rev. 2 →   +2 Count length of prefix and suffix such that all characters in the prefix/suffix are equal.if prefix == n, answer is n * (n+1) /2if first char == last char, answer is (prefix+1) * (suffix+1)else the answer is 1 + prefix + suffixEdit: first case won't happen
•  » » » 21 month(s) ago, # ^ |   0 https://codeforces.com/contest/1096/submission/47648603 is it not correct then?
•  » » » » 21 month(s) ago, # ^ |   0 It is wrong due to overflow of int ans. Replace itwith long long, it will be accepte.
•  » » » » » 21 month(s) ago, # ^ |   0 HF
•  » » » 21 month(s) ago, # ^ |   +4 I think the first case won't be used, as its given in the question that there are at least 2 distinct characters.
•  » » » » 21 month(s) ago, # ^ |   0 Ah yes good point
•  » » » 21 month(s) ago, # ^ | ← Rev. 3 →   0 Can u please explain this
•  » » » 21 month(s) ago, # ^ |   0 can u tell me how u derive the 2nd case?
•  » » » » 21 month(s) ago, # ^ |   0 First char == last char means you have a string that looks something like aaabcaaaAny way that you split the string will work if it excludes the 'bc'. Consider this: |a|a|a|bc|a|a|a| Choose two bars, one of left of bc, one on right — that represents a substring that you remove. Note that there are p+1=4 bars on each side, p being number of a's on each side. Because you are taking one from each side, the answer is (prefix + 1) * (suffix + 1)
•  » » » » » 21 month(s) ago, # ^ |   0 got it thanx
•  » » » 21 month(s) ago, # ^ |   0 How do you derive the last case?
•  » » » » 21 month(s) ago, # ^ | ← Rev. 2 →   0 Say you have this: |a|a|a|cc|b|b|b| Each bar to the left of the "cc" represents a substring that you can remove (from the bar to the right). Each bar to the right is a substring from the bar to the left.
•  » » » 21 month(s) ago, # ^ | ← Rev. 2 →   0 [user:goloins] can you please tell the answer to "aabee" ??/according to conditions mentioned by you answer should be 5 but it is coming 7!!! I may be wrong..hopefully you can point out my mistake
•  » » » » 21 month(s) ago, # ^ |   0 The answer should be 5. The resulting strings are "", "a", "aa", "e", "ee"
•  » » » » » 21 month(s) ago, # ^ |   0 what if we take out substring "abe" and "b" from the middle??? we can do that..can we??
•  » » » » » » 21 month(s) ago, # ^ |   0 no. if we do that we are not left with same type of characters.
•  » » » » » » » 21 month(s) ago, # ^ |   0 oh ok...i got it..thanks
 » 21 month(s) ago, # |   +19 is this eduround 998244353?
 » 21 month(s) ago, # |   0 What was wrong with C? I messed it up :(
•  » » 21 month(s) ago, # ^ |   0 It showed me Wrong answer on test 1But it was correct
 » 21 month(s) ago, # |   0 Am I the only one who stupidly thought B answer is x*(x+1)/2
•  » » 21 month(s) ago, # ^ | ← Rev. 2 →   +21 I'll take that as a yes
 » 21 month(s) ago, # |   +5 Is D f(i,j) = min ans for prefix i such that starting j letters of hard are taken.
•  » » 21 month(s) ago, # ^ |   0 i don't know, but my solution is this rsrs.
•  » » 21 month(s) ago, # ^ |   0 Yeah, that dp should work.
•  » » » 21 month(s) ago, # ^ | ← Rev. 3 →   0 I could be missing something obvious but I don't understand why that dp works ? Could you please explain ?EDIT: Maybe I just dont understand what "starting j letters of hard are taken" means here. Could someone just elaborate on that ?
•  » » » » 21 month(s) ago, # ^ |   +3 Minimum cost we can obtain from prefix till index i such that the resultant subsequence contains first j characters from string "hard" in order. Then you can do DP : 47674309
 » 21 month(s) ago, # |   +1 I got WA on test case 4 for problem D, does anyone know what could be wrong 47654263
•  » » 21 month(s) ago, # ^ | ← Rev. 16 →   +1 Me too :( 47654227
•  » » 21 month(s) ago, # ^ | ← Rev. 2 →   +14 Test 4 catches a lot of bugs; from a quick scan of your code, it seems like you made the assumption that the solution must be removing all the occurrences of one letter. This isn't the case. Consider if the string is "harard", where the first a and the last r are very cheap to remove, but everything else is very expensive. Removing those two letters would be the solution.The general problem is solved using DP.
•  » » » 21 month(s) ago, # ^ |   +9 Thanks! I indeed made that flawed assumption.
•  » » » 21 month(s) ago, # ^ |   0 Thank you very much for that test case. I also made that assumption but there was no way of figuring that out from test case 4.
 » 21 month(s) ago, # |   +1 the solution for C for god sake?
•  » » 21 month(s) ago, # ^ | ← Rev. 3 →   0 Multiple of pi(180) which is multiple of alpha angle. Also check that internal angle obtained is greater than or equal to alpha angle.
•  » » 21 month(s) ago, # ^ |   0 for every side length k from 3 to 360:smallest angle = 360/(k*2) biggest angle = 180-360/kevery angle in between is a multiple of the smallest angle. If the angle you're being asked is between the smallest and biggest angle and it is a multiple of the smallest angle, then the answer is k.
•  » » » 21 month(s) ago, # ^ | ← Rev. 9 →   +9 please tell the proof regarding "every angle in between is a multiple of smallest angle"
•  » » » » 21 month(s) ago, # ^ |   +8 Imagine the polygon as a circle with points on it.The inscribed angle theorem relates length of curve to the angle. https://www.mathsisfun.com/geometry/circle-theorems.htmlThe smallest angle represents the arclength between two adjacent points, and every possible angle represents the arclength of some integer * the smallest possible arclength.
•  » » » » » 21 month(s) ago, # ^ |   +3 thanks buddy :)
•  » » » » » » 21 month(s) ago, # ^ |   +1 no problem bro :)
•  » » » » 21 month(s) ago, # ^ | ← Rev. 3 →   +4 essentially any regular n sided shape can be placed inside a circle. any angle is the sum of the different smallest triangles that divide up the shape around an arbitrary point. circle geometry states that because some of the angles subtend equal arcs/segments then the smallest angles must also be equal, and hence any angle formed must be a multiple of the smallest angleedit: ok you responded by the time i send this.
•  » » » 21 month(s) ago, # ^ |   0 How did u came to the conclusion that all angles in between are multiple of smallest angle?
•  » » » » 21 month(s) ago, # ^ |   0 Math, dude.
•  » » » 21 month(s) ago, # ^ |   0 Why do we iterate only till 360?
•  » » 21 month(s) ago, # ^ | ← Rev. 9 →   +2 I've solved it and here is a link to my solution: https://codeforces.com/contest/1096/submission/47665926You may want to read below to understand it.EXPLANATION:It's a property from grade 10 (high school) maths.If you draw a circumscribed circle around the regular polygon, the angle subtended (by any two vertices/arc) at the centre of the polygon will always be double of angle subtended anywhere on the circle.Here is a youtube link if you want the proof: https://www.youtube.com/watch?v=MyzGVbCHh5M============ Steps ===========1) The input needs us to find a suitable "n" for a given query angle "q". What we do is find suitable "n" for angle subtended at the centre of the circle. which is 2* q.2) But how do we find "n" ?Total angle subtended at the centre of a circle by any two vertices can be a max of 360 (to be precise, some decimal value < 360). Hence if you have "n" vertices, you can "distribute" this 360 between the vertices.What I mean by that is that if there are 10 vertices, then every 2 adjacent vertices will subtend 360/10 (=36) at the centre.To find "n", we need to use a loop , eg: for(n = 3; n <= 360; ++n) Start from n = 3, so that you can get minimum "n" once below condition is satisfied. On finding it, break from the loop.// NOTE: For this problem, "360/n" must also be an integer. Hence you must // ignore values of "n" if "360 % n != 0"if( (2*q) % (360/n) == 0 ) { // found n. //Break from loop if you have structured your code that way.}This condition means that if our required subtended angle (2*q) is a multiple of the minimum possible subtended angle for a given "n", then we have found "n" (there is an edge case, see Note below)=======FINAL NOTE: There is an edge case in the sample input and output given in the problem statement, the 4th input (178) has output 180, and not 90. this is hard to explain in words but much easier to understand visually. I have commented about this in my solution (linked above) as well. Please see that comment and try drawing it out if you don't follow.
•  » » » 21 month(s) ago, # ^ | ← Rev. 3 →   0 can u please elaborate more for 4th input 178?If the required subtended angle > 180, then you have to ensure that if you find a "n", there must be a gap of at least 1 vertex between two vertices that subtend the required angle. why so???and how is that implemented by this way:-An equivalent way to form this is checking if the minimum subtended angle is not == complement angle.
•  » » » » 21 month(s) ago, # ^ | ← Rev. 4 →   0 Hi padamprakash,First see this diagram: https://ibb.co/TTG787k and then read below. I will answer both your questions in the order you have asked them:1) Let's say the angle in the query is "q". Hence we need to find two vertices that subtend this angle at a 3rd vertex. A reminder of some math theory: Any two points on a circle form 2 arcs: Major and minor arc.If angle subtended at centre (2*q) is obtuse, then we are dealing with the major arc for the two vertices. If there is no vertex between them (means they are adjacent/consecutive vertices), then the major arc cannot subtend the angle "q" at a vertex between them !2) Let's take an example case, same as input 4 in problem set.q = 178.2*q = 356356 is > 180.Complement of 356 is 4 (360-4)If the minimum subtended angle = 4, then this means that any two adjacent/consecutive vertices subtend an angle of 4 at the centre of the circle. This means there is no gap between them !^^^ Hope that is clear.
•  » » » 21 month(s) ago, # ^ | ← Rev. 2 →   0 I can't believe I missed the central/peripheral angle thing.
 » 21 month(s) ago, # |   +1 What's test case 3 in C?
 » 21 month(s) ago, # |   +10 Did someone get AC on G with FFT (not NTT)?
•  » » 21 month(s) ago, # ^ |   +19 Not even with TNT man. that problem is really hard.
•  » » 21 month(s) ago, # ^ |   +10 neal did it 47640712
•  » » 21 month(s) ago, # ^ |   +24 I did it. To avoid precision error, I used the well-known technique that decomposes each integer into two parts. Calculate both on the real and imaginary part to reduce some factors. Basically, it's the template that tourist uses, very well-implemented and works with arbitrary modulos.
 » 21 month(s) ago, # |   -41 These guys are really good :D
•  » » 21 month(s) ago, # ^ |   +39 Is it that you didn't read problem F and G, or just that you're too weak to learn how to solve them?
•  » » » 21 month(s) ago, # ^ |   0 well well, look who is a Legendary grandmaster and who is a Specialist now
 » 21 month(s) ago, # |   +10 This user is hoax and the person who hacks his solution needs to be reported or taken down !! https://codeforces.com/profile/problem_destroyer420 Returns 0 for a particular n and voila hack from another id !
•  » » 21 month(s) ago, # ^ |   -27 Mind your own GOD DAMN business!!!
•  » » 21 month(s) ago, # ^ |   -30 Prove that the two accounts have something in common. Basically all you do now is accusing 2 innocent people without any proof. Go learn some programming, green boi
•  » » 21 month(s) ago, # ^ |   -20 I guess u r subscribed to T Series. Get out of my sight
 » 21 month(s) ago, # |   0 C had a nice corner case and D was a nice problem in general. Enjoyed the problems, although it seems difficulty for tail end of problems was slightly mis-estimated.
•  » » 21 month(s) ago, # ^ |   0 What's the corner case on C?
•  » » » 21 month(s) ago, # ^ |   0 179 -> 360
•  » » » 21 month(s) ago, # ^ | ← Rev. 3 →   0 When , n should be doubled.That's because there must be a vertex between a and c.
•  » » 21 month(s) ago, # ^ |   0 can u help me with solution for C?
 » 21 month(s) ago, # |   0 PikMikehttps://codeforces.com/contest/1096/submission/47652681What is wrong with this? In my compiler it shows correct!
•  » » 21 month(s) ago, # ^ |   0 The output is just different... if your compiler is not giving the same answer you should make sure they are consistent but I feel it may just be you not looking closlely
•  » » » 21 month(s) ago, # ^ |   0 Please check in yours. Then you will see
•  » » » » 21 month(s) ago, # ^ |   0 Ok, I got 18 on my compiler too. We must both be using a compiler not like codeforces. The only difference I can think of is the way division happens, with your code, a slight difference could cause floating point errors. If you don't use any doubles you may be able to get the right answer (and it is better to not use doubles anyways, it will likely break on later test cases even with your compiler)
•  » » » » » 21 month(s) ago, # ^ |   -18 I don't care cf compiler. Make me expert MikeMirzayanov!
•  » » » » » » 21 month(s) ago, # ^ |   0 You should take care of precision errors. int(x) is a bad way to round a double, since if you get 0.9999999 instead of 1.00000, int(x) returns 1.
•  » » » » » » » 21 month(s) ago, # ^ | ← Rev. 2 →   +1 what is the best way to round-off whenever needed? Is (int)(floor(x)) always fine?
•  » » » » » » » » 21 month(s) ago, # ^ | ← Rev. 2 →   +5 Firstly, it's always better to work with integral datatypes if it is possible.And secondly, (int)(floor(x)) is bad because of the same reasons. Typically (int)(x + EPS) works well, where EPS is somewhere around 10 - 9, provided that x is non-negative.
•  » » » » » » » » » 21 month(s) ago, # ^ |   0 Thanks :)
•  » » » » » » 21 month(s) ago, # ^ | ← Rev. 2 →   0 Maybe your code isn't so robust. Please avoid using doubles if possible. Actually, I think it more important for you to learn how to solve it without doubles. Good luck at Goodbye 2018! Wish you expert next time.
 » 21 month(s) ago, # |   +11 Fake hack: applese hacked __123456__'s submission to problem A. It has a special if for failing on purpose:https://codeforces.com/contest/1096/submission/47640777
 » 21 month(s) ago, # |   0 I got WA on test 4 for problem B, does anyone know what could be wrong 47654945
•  » » 21 month(s) ago, # ^ |   0 Integer overflow in line 36.
•  » » » 21 month(s) ago, # ^ |   0 thanks,but i am a little confuse that why it would be overflow,i think the fr and en should be lower than 2*10^5.
•  » » » » 21 month(s) ago, # ^ |   0 But fr*en will be 10^10 which will overflow
 » 21 month(s) ago, # |   0 How to solve D?I assumed that it is optimal to delete only one type of character. Is this assumption incorrect?
•  » » 21 month(s) ago, # ^ |   0 DP[i][j] = minimum cost to delete the first 'j' characters of "hard" from prefix i.That assumption is incorrect.
 » 21 month(s) ago, # |   +6 On problem G. I used Divide and Conquer + polynomial multiplication ,but get TLE However, if someone had used dft & fastpow & idft , he would have ACMy IQ is not enough to figure out the second way(it's 23:30 in China), but these two ways have the same time complexity O(nlogn) Although I think it is ok not to let me pass, but I'm very sad. With this problem I would become Orange(my current rating is 2097)TAT
•  » » 21 month(s) ago, # ^ |   +24 It's just the issue with constant. Well-implemented FFT can pass,too.
•  » » 21 month(s) ago, # ^ |   0 D&C + polynomail multiplication is .Or did you use some special version of D&C?
•  » » » 21 month(s) ago, # ^ |   0 No. With the equation , you can see that . Same complexity with polynomial inverse/exponentiation/logarithm and some other operations.
•  » » » » 21 month(s) ago, # ^ |   +8 In D&C it's , if it's implemented just like ''divide the segment into two, solve recursively and then combine answers with polynomial multiplication''.
•  » » » » » 21 month(s) ago, # ^ |   0 Yes. But here we are exponentiating a polynomial, and we only need to calculate one half, and the other half is the same, and thus the 2 factor is gone. You can implement it use fast exponentiation just like exponentiating integers. Time complexity is .
•  » » » » » » 21 month(s) ago, # ^ |   +8 Yes. It's one of model solutions. But New_Journey's solution lacks this optimization, so it's TL.
•  » » » » » » » 21 month(s) ago, # ^ |   +1 Okay.
•  » » » » » » » » 21 month(s) ago, # ^ |   0 I think I know why I TLEMy brain is completely offline Ahhhhhhhh
 » 21 month(s) ago, # |   0 Problem F is similar to SRM 470 Division 1 — Level Two
 » 21 month(s) ago, # |   0 I want to check if my code is wrong, so I hack myself.I write a program in python3 to hack problem C: print("180") for i in range(1, 180): print(i) but system said "Validator 'val.exe' returns exit code 3 [FAIL Unexpected end of file — token expected (stdin, line 181)]", can somebody help me to solve this problem?
•  » » 21 month(s) ago, # ^ |   0 Print 179 instead of 180
•  » » 21 month(s) ago, # ^ |   0 range(1,180) is only 179 numbers, since the last value is exclusive. You promised 180 test cases.
•  » » 21 month(s) ago, # ^ |   +1 I think all cases are included in pretest 3.
 » 21 month(s) ago, # |   +1 For problem G, could someone provide an explanation of how to deal with MOD in fft?
•  » » 21 month(s) ago, # ^ |   +5 Refer to NTT Ahmed- Link: https://codeforces.com/blog/entry/48798 You can also deal with MOD in FFT:(See trick number 17) https://codeforces.com/blog/entry/48417
•  » » » 21 month(s) ago, # ^ |   +5 Thanks a lot, I'll definitely read them.
 » 21 month(s) ago, # |   +11 How can someone hack problem C if they have included all possible values of angle in pretest #3?
•  » » 21 month(s) ago, # ^ |   +2 For example when someone has an "if (time(0) > x) exit(0);" and time(0) is now greater than x while it was smaller during contest, the solution will fail when a hack is performed now. Example given: https://codeforces.com/contest/1088/submission/46594591 . Although it's totally useless to have this in your code, it's a possible way to hack C now.
 » 21 month(s) ago, # |   +27 To problemsetters, G is definitely a cool problem. However, do you really think it is suitable for contests rated for Div2? This problem could be easily solved by just copying FFT templates. I think this not fair to the newcomers who has problem solving skills but didn't know much algorithm yet. I think putting these kind of problems in the problemset will cause the rating to be less accurate.
•  » » 21 month(s) ago, # ^ |   +61 Even though ERs sound like regular Div2 and behave like regular Div2, we (authors) still believe that it's not a regular Div2. That's why we allow ourselves more freedom in using "well-known" ideas (but still trying hard to find a balance).Of course, it will lead to some disturbance of ratings, but it's a thing we should deal with.On the other hand, if newcomers wouldn't confront new for themselves but famous in community tasks, they will not learn them. And I think, ER is a perfect place to meet with such tasks.
•  » » » 21 month(s) ago, # ^ |   +9 I agree. If it wasn't for educational rounds, this task would not fit anywhere on Codeforces. It's too easy for Div 1 D/E, and putting it in a regular div2 round seems strictly worse than putting it in a educational round.
 » 21 month(s) ago, # |   0 In problem A, in the output format it is clearly stated that the answer in the i-th line should correspond to the i-th query but I just saw a submission who has printed l and 2*l in seperate lines but the verdict is ok. Is it actually fine to print it on seperate lines?
•  » » 21 month(s) ago, # ^ |   0 not good
 » 21 month(s) ago, # |   +33 It be like that sometimes.
 » 21 month(s) ago, # |   -54 please stop making contests
 » 21 month(s) ago, # | ← Rev. 2 →   0 How to solve F ? Or atleast is there a way to find total number of inversions among all the n! permutations
•  » » 21 month(s) ago, # ^ |   0 It's just . Use the linearity of expectations.
•  » » » 21 month(s) ago, # ^ | ← Rev. 3 →   0 Ok. I now googled and Got it for no of inversions for n!. Any how thanks for replying. But how is that n! * n * (n-1) / 4 ? Can you plz show me the proof or method of deriving it ?
•  » » » » 21 month(s) ago, # ^ |   0 For a single random permutation, 0 inversions is the best case, n*(n-1)/2 is the worst case. Due to symmetry (you can remap i -> n-i+1), the expected value is n*(n-1)/4
•  » » » » 21 month(s) ago, # ^ |   +24 For every permutation, you can take it along with its reverse permutation. Every possible inversion happens in either the permutation or its reverse. This implies that the average number of inversions is n * (n — 1) / 4.
 » 21 month(s) ago, # |   0 how to do C?
•  » » 21 month(s) ago, # ^ | ← Rev. 3 →   0 Handle ang = 179 separately, n= 360;(This is because for every angle less than 179, we can attain it using a polygon with no. of sides n <=180)For other values of ang:Start with no. of sides s = min(3, ceil(360/(180-ang)))[This checks if the minimum angle possible in the polygon is greater than or equal to ang ] This was derived from, angle of a regular n-gon = (n-2)*180/n;Now we need to satisfy,i*ang == j*180; (for some s<=i<=180, and j
•  » » 21 month(s) ago, # ^ | ← Rev. 2 →   0 Let t = gcd(180, ang). Result will be  - 1 if ang = 180, if , otherwise
 » 21 month(s) ago, # |   +8 When you have no idea for C, so you decide to build regular polygons and check all angles between them until you've precomputed the answer for all angles...
 » 21 month(s) ago, # |   0 Peace on You All :D I Have a question in "D" Problem .. Why my Greedy Solution is Wrong ?HereThe Idea Is , If i delete all character ( 'h' , 'a' , 'r', or 'd' ) it will be impossible to get subsequence = "hard" is that right ? but this is not the all answer the rest is coming this is how i choose characters to delete character "d" i delete if there is a subsequence = "har" before . character "r" i delete if there is a subsequence = "ha" before and i will walk to last "d" i choose to delete .character "a" i delete if there is a character = "h" before and i will walk to last "r" i choose to delete .character "h" i delete and i will walk to last "a" i choose to delete .and i will print the Minimum of all that . Why This is Wrong !
•  » » 21 month(s) ago, # ^ |   +1 I think my solution is similar to yours, however, I find the greedy solution will not work for the following case: "harard", [100, 1, 100, 100, 1, 100]. The minimum cost is 2 when you remove 'a' at 2 and 'r' at 5, and the result string is 'hrad'. It takes me a long time to figure out this, I'm still working on understanding the DP solution after checking the accepted code from others...
•  » » » 21 month(s) ago, # ^ |   0 Thank you :D
 » 21 month(s) ago, # | ← Rev. 2 →   +5 In problem C, that line print −1 if there is no such n made me question myself a several times.
 » 21 month(s) ago, # |   0 I have no idea how to solve C , can anyone help how to solve ?
•  » » 21 month(s) ago, # ^ |   0 Please refer to this :)
•  » » » 21 month(s) ago, # ^ |   0 Thanx
 » 21 month(s) ago, # |   +8 so much math ._.
 » 21 month(s) ago, # |   +21 I think ideally, an accepted problem C cannot be hacked nor fail main tests. As the pre-test 3 checks all possible 1<=ang<=179.
 » 21 month(s) ago, # |   0 In what complexity should E be solved? My O(N*S*2) solution doesn't pass.
 » 21 month(s) ago, # | ← Rev. 2 →   0 can someone explain intuition behind D? i tried some people's solutions and coded them but i still don't fully understand them.
•  » » 21 month(s) ago, # ^ |   +4 Intuition: Kind of modification of the classic 0-1 knapsack DP problem.For more clarity please look into my top-down implementation of the same.
•  » » » 21 month(s) ago, # ^ |   +1 thanks!
•  » » » » 21 month(s) ago, # ^ |   0 Glad it helped :)
 » 21 month(s) ago, # |   0 i don't know why the answer of task 178 is 180, but not 90 on problem C!!!
•  » » 21 month(s) ago, # ^ |   +11 It is true that you can form angles in increments of 2 with a polygon of size 90. However, the max angle you can form is 176 ((n-2)*180/n).
•  » » 21 month(s) ago, # ^ |   +5 Build a regular 90-gon and try to find out yourself lmao.
 » 21 month(s) ago, # |   0 what meme around number 998244353?
•  » » 21 month(s) ago, # ^ |   0 Needed for NTT, one of the solutions for problem G. Specifically, NTT needs that your prime modulo be off the form n*2^k +1. That mod fits. Presumably, they used it through the whole contest to not give too much away.
 » 21 month(s) ago, # |   0 In problem C, why is answer always for sides between 3 and 360 ? Can't answer exceed 360 ?
•  » » 21 month(s) ago, # ^ |   0 angle is 1<=ang<180. minimum angle is 1 so for n=360 min angle is 0.5 and the maximum angle is 359.
•  » » » 21 month(s) ago, # ^ |   0 I understood it. But for n=360 minimum is 0.5 and maximum is 179. For deg=180 answer would be -1.
 » 21 month(s) ago, # |   0 Can anyone explain the logic of D?
•  » » 21 month(s) ago, # ^ | ← Rev. 2 →   0 dp[i][j] is minimum ambiguity when we are at prefix j of string "hard". So,we are at state (i,j) and in next index (prefix j+1) comes, we have two choice, either to remove that letter or continue without removing(increasing prefix) and in next index any other letter arrives,we will be in same state. hence transition will be if(next index is next character after j) dp(i,j)=min(dp(i+1,j+1),dp(i+1,j)+a[i+1]) else dp(i,j)=(dp(i+1,j)).
 » 21 month(s) ago, # |   +9 when will be the editorial released?
 » 21 month(s) ago, # |   0 How to take random result in problem A ???
•  » » 21 month(s) ago, # ^ |   0 just print(ans, ans*2)..that's enough since it is the best case and the problemsetter said that it is guaranteed that the answer exist
 » 21 month(s) ago, # |   0 Can you explain the algorithm of C??
•  » » 21 month(s) ago, # ^ |   0
 » 21 month(s) ago, # |   0 After reading problem D, i think that maybe easy. After thinking for a long time, i realize that too hard. :((
 » 21 month(s) ago, # |   0 Auto comment: topic has been updated by PikMike (previous revision, new revision, compare).
 » 21 month(s) ago, # |   0 Auto comment: topic has been updated by PikMike (previous revision, new revision, compare).