### LeiviniaBirdway's blog

By LeiviniaBirdway, history, 3 months ago, ,

Good day, Codeforces! Or in my language, magandang araw, Codeforces!

Codeforces Round #597 (Div. 2) will be held on Nov/01/2019 17:35 (Moscow time). Is it rated? Yes, but only for participants below 2100 rating.

Of course, this round is not made by me alone. So, I would like to thank the following people for their help in making this round possible:

There will be 6 problems, and you will be given 2 hours to solve them.

The scoring distribution is as follows: 750-750-1250-1750-2250-2500.

I hope you enjoy the round!

Update: editorial is out now

• +513

 » 3 months ago, # | ← Rev. 2 →   +128 best round i ever tested. keima orz
•  » » 3 months ago, # ^ |   +160 Have you forgotten that you were testing my round
•  » » » 3 months ago, # ^ |   +80 best round I ever tested
•  » » » » 3 months ago, # ^ |   -56 The worst round I've ever solved..
•  » » » 3 months ago, # ^ |   -32 worst round I ever tested
•  » » » » 3 months ago, # ^ |   +22 worst lie you ever lied
•  » » » » » 3 months ago, # ^ |   +7 they just forgot to insert me :)
•  » » » » » » 3 months ago, # ^ | ← Rev. 2 →   +17 best thing they don't insert you .
•  » » » 3 months ago, # ^ |   0 NO
•  » » 3 months ago, # ^ |   -7 keima orz
•  » » 3 months ago, # ^ |   -33 I'm pretty sure it will be another bad contest. If you agree, upvote me.
•  » » 3 months ago, # ^ |   +65 best round i didnt tested
•  » » » 3 months ago, # ^ |   +6 r/technicallythetruth
•  » » 3 months ago, # ^ |   -21 Your comment gave me goosebumps.
•  » » 3 months ago, # ^ |   +14 *tasted
 » 3 months ago, # |   0 Best of luck for your first contest.
 » 3 months ago, # |   0 Are you the first one from Philippines to make a contest on codeforces ?
•  » » 3 months ago, # ^ |   +3 No. robinyu made Codeforces Round #419, https://codeforces.com/blog/entry/52653.
•  » » » 3 months ago, # ^ |   0 I want to AK it,but I can't.
 » 3 months ago, # |   -8 I hope I can become candidate master after this round :DDDDDDDDD
•  » » 3 months ago, # ^ |   -14 I hope, that this round will be balanced, and all people get results, they needed.
 » 3 months ago, # |   +91 After almost 3 years I am back on CodeForces and gonna participate in this round. Wish me luck!
•  » » 3 months ago, # ^ |   +38 You lied. You didn't participate in this round.
 » 3 months ago, # |   +18 It clashes with a codechef round , but after reading comments from testers ,it seems like, i should ditch that and participate here ...
•  » » 3 months ago, # ^ |   +55 best choice ever made
•  » » » 3 months ago, # ^ |   0 Same here I also ditched codechefs round and got +83 here
 » 3 months ago, # |   +10 I think it must be one of the best contests in Codeforces!
•  » » 3 months ago, # ^ |   0 i think the same
 » 3 months ago, # |   +17 I wish contest has strong pretests. I don't like to take wrong answers on main tests.
•  » » 3 months ago, # ^ |   +2 Whenever 300iq was taster , 193 tastcase passed and then suddenly wrong answer in tastcase 194
 » 3 months ago, # |   +51 As a tester, I enjoyed solving problems. Well written problem statements mixed with Chinese culture. One of the problems is about a childhood game and it was completely interesting for me!
•  » » 3 months ago, # ^ |   +9 how interesting would it be a D or E problem about game theory :P
•  » » » 3 months ago, # ^ | ← Rev. 2 →   -18 It'll be interesting if C was combinatorics :P
•  » » 3 months ago, # ^ |   +11 I hope it is not interactive, I had bad luck trying to interact with my Chinese friends' kids!
 » 3 months ago, # |   +10 Keima915 OP, from green to orange in 7 months .. interested about the contest to start my 7 months journey :p
•  » » 3 months ago, # ^ |   +15 I think it's not that hard. Good luck!
 » 3 months ago, # |   +1 hope solve a,b,c
 » 3 months ago, # |   +5 Please can anyone say me this round I wanna be specialist how many problems must I solve
•  » » 3 months ago, # ^ |   +12 Like what you did in your last round.
•  » » » 3 months ago, # ^ |   0 How can I improve? advise me something.I already participated 27 contests result is newbie.
•  » » » » 3 months ago, # ^ |   +5 Always getting out of your comfort zone. And focusing on fixing your mistakes.
•  » » 3 months ago, # ^ |   +10 I think you only need solve 2 problems in short time or 3 problems
•  » » » 3 months ago, # ^ |   0 How they calculate it to be specialist?
•  » » » » 3 months ago, # ^ |   0 By your relative ranking to other people, and your previous rating vs. other people's ratings around your ranking
•  » » » » » 3 months ago, # ^ |   +13 huh.. very complicated, i will go and change the css to red.
•  » » » » 3 months ago, # ^ |   +17 It's very trouble :<
 » 3 months ago, # |   0 Expect for the constest!
•  » » 3 months ago, # ^ |   0 want for the contest!
 » 3 months ago, # |   +4 I wish I can get expert in the contest again. :)Good luck to everyone!
 » 3 months ago, # |   +21 I m back Bois.. Had a busy October but now I am back to top the charts again.
 » 3 months ago, # |   +10 The contestants had to face some difficulty in the previous contest due to several server failure. Though it was overcome in few seconds but its disappointing to reload the page over and over again during the contest hour. Div-2 rating changes also had to roll back because of some problems and we had to wait for several hours to get the rating changes in the last contest. Hope the authority will take care of these matters in this round.
 » 3 months ago, # |   0 Auto comment: topic has been updated by keima915 (previous revision, new revision, compare).
 » 3 months ago, # |   0 Best of luck in your first contest!
 » 3 months ago, # |   0 Why first and second question has same score distribution....does that mean they have same difficulty level??
•  » » 3 months ago, # ^ | ← Rev. 3 →   -8 Not like that
 » 3 months ago, # |   0 how can be a tester?
 » 3 months ago, # | ← Rev. 2 →   -8 Hope we have a fair race :)
 » 3 months ago, # |   -8 I hope that I can turn it into a blue name.
 » 3 months ago, # | ← Rev. 2 →   -35 Another DISGUSTING reading contest.
•  » » 3 months ago, # ^ |   +17 Reading is also a part of CP. So you should adjust yourself to read long questions. Else make the question look smaller to you. How? You figure it out ;).
•  » » » 3 months ago, # ^ | ← Rev. 2 →   -15 I don't like to read tonns of text after hard work day. It tires the brain completely.
•  » » » » 3 months ago, # ^ |   +14 Do you think everyone is only doing CP? Are they not tired?. Let's not make any excuses and just read the question there is no other way.
•  » » » » » 3 months ago, # ^ |   -15 I don't care about others. Comments were invented in order for people to explain PERSONAL opinion.
•  » » 3 months ago, # ^ |   0 Well, I guess that's just your excuse for not being able to solve problems on this contest. The statements were actually well written and short. Go practice instead of complaining.
•  » » » 3 months ago, # ^ |   +22 Well, I don't know if the statements were well-written but problem E's statement is definitely not short.
•  » » » » 3 months ago, # ^ |   +8 You're right, they were well written except for E. When I saw that statement I didn't even try to read it and went for problem F.
•  » » » 3 months ago, # ^ |   -12 I didn't even tried. Maybe you're right, I don't able to solve problems, but also i do not want to read giant problem statements.
 » 3 months ago, # | ← Rev. 3 →   0 strong pre test cases for problems at code forces I ever seen!!
•  » » 3 months ago, # ^ |   +5 Strongest pretest 13 I have ever seen
 » 3 months ago, # |   +4 Wrong answer on pretest 13 on problem D, No idea why. :(Any one have idea what is going on in pretest 13 ?
 » 3 months ago, # | ← Rev. 2 →   0 TC 9 of problem C?
•  » » 3 months ago, # ^ |   0 Were u taking modulo when calculating the fibonacci ????
•  » » 3 months ago, # ^ |   0 That test case got me too. I spent the last hour trying to fix whatever was wrong my fibonacci-number calculator.I was modding by 10^9+7 everywhere I could see, but for some reason, my 89-th and onward Fib numbers were wrong. So of course the Fib products were also wrong too. Please send help
•  » » » 3 months ago, # ^ |   +3 I think. You should replace ret*=fibNum(x); as ret = (ret * 1ll * fibNum(x)) % M and also temp = (temp1 * 1ll * temp2) % M;
•  » » » » 3 months ago, # ^ |   0 Not sure what the || (or? or something else...) is meant to do or what difference ret*=a vs ret=ret*a would make, care to explain?
•  » » » » » 3 months ago, # ^ |   +4 I think he means 1LL. LL makes it to long long
•  » » » » » 3 months ago, # ^ |   +2 that is 1LL.which leads to long long int.
•  » » » » » 3 months ago, # ^ |   0 Your solution will get AC after doing that.
•  » » » » » » 3 months ago, # ^ |   0 Thank you so much for explaining that starboy_jb. I will never forget to cast again.
•  » » 3 months ago, # ^ |   +3 If you need help tell the approach of your solution rather than asking what was the test case. After some time you will get to know it right? :)
•  » » » 3 months ago, # ^ | ← Rev. 2 →   0 I found out that ways to arrange characters of length i which are consecutive, can be found out by this formula,Pseudocode if(i is even) dp[i] = dp[i-1]*2 +1; else dp[i] = dp[i-1]*2 - 1; In my solution, i was doing like this:  dp[0] = dp[1] = 0LL; dp[2] = 2LL; dp[3] = 3LL; for(int i=4;i<=sz(s);i++){ dp[i] = (dp[i-1]*2LL)%MOD; if(i%2) dp[i] = (dp[i]+1LL)%MOD; else dp[i] = (dp[i]-1LL + MOD)%MOD; //cout<
•  » » » » 3 months ago, # ^ | ← Rev. 2 →   +3 First of all, your first "if" statement has identical branches.(now ok)Secondly, dp[1] should be 1Thirdly, by the formula you have given dp[4] = dp[3] * 2 + 1 = 7, but actually dp[4] = 5. For example : intput:uuuu1.uuuu 2.wuu 3.uwu 4.uuw 5.ww
•  » » » » » 3 months ago, # ^ |   0 Here is my output of first 10 numbers. Check once again, i think you are misreading something. 4 5 5 11 6 21 7 43 8 85 9 171 10 341 
•  » » » » » » 3 months ago, # ^ |   0 dp[5] = 8 not 11
•  » » » » » » » 3 months ago, # ^ |   0 Then how I was able to pass 8 test cases? lol
•  » » » » » » » » 3 months ago, # ^ |   0 till 8 TC,the continuous occurrence of n and u is not greater than 4.
•  » » » » » » » 3 months ago, # ^ |   0 Thanks anyways, I was calculating repeating cases again and again. 1.uuuuu 2.wuuu 3. wwu 4.wuw 5.uwuu 6.uww 7.uuwu 8.wwu 9.uuuw 10.wuw 11.uww where 8,10 and 11 are repeating. Wasted 1 hour thinking about something wrong with computations.Thank you :)
•  » » » » » » 3 months ago, # ^ |   0 I calculated according to your first two lines of your comment (the if else part), you said dp[i] = dp[i-1] * 2 + 1 if i is even, maybe you have mistaken even with odd there, anyway, your formula is incorrect I guess.
 » 3 months ago, # |   +17 how to solve D?
•  » » 3 months ago, # ^ |   +3 Kruskal or Prim to find smallest tree. However the graph must be modified a little bit. Add a new node (let's say it's the power supply for the power stations) and the edge from this source to each of n nodes is equal to the cost to build a station there.
•  » » » 3 months ago, # ^ |   0 Dont we need to make sure that there is atleast one power station? Wouldnt your approach fail when the power stations cost are really high, but the points are close by?
•  » » » » 3 months ago, # ^ |   0 However, your minimum spanning tree will also need to include the new node, which represents a sort of "super power supply" and ensures that at least one node is connected to the new node, and thus has a power station.
•  » » » » 3 months ago, # ^ |   0 Hmm? a tree is a connected graph, thus the newly added node (power supply) must belong to tree too. If the power supply is connected to node i, then you put a station at node i. Since the supply is always connected to some city because of connectedness, there is always at least one power station.
•  » » » » 3 months ago, # ^ |   0 No because we are finding a spanning tree which is connected if the original graph is connected too thus there'll be a path from the power station to every city.
 » 3 months ago, # |   +25 What the hell was pretest 13 in D :(((
•  » » 3 months ago, # ^ | ← Rev. 2 →   0 Did you consider the case when $(x_i, y_i) = (x_j, y_j)$ even if $i!= j$. I think this is the mistake, I am not sure though, because I too got wrong answer on test case $13$. I didn't consider this case, so maybe this is the mistake I made.
•  » » » 3 months ago, # ^ | ← Rev. 2 →   +6 IS it matters? Because dijkstra will take care of this fact I guess. CAn you please give the example by which you debug your code?
•  » » » 3 months ago, # ^ |   0 I considered this case. I was not finding MST though, which I think was the expected soln
 » 3 months ago, # |   0 approach for problem C?
•  » » 3 months ago, # ^ |   +3 I was getting some kind of fibonacci sequence
•  » » 3 months ago, # ^ |   0 say we have len length of string of either n or u, in how many ways we can make pair in the string so if we make x pairs of 'n' ,we are left with len-2*x 'n' characters and we have x+1 blocks where we can fill them , so distribute len-2*x objects among x+1 persons such that each get zero or more with (len-x,x) waysand iterate x from 0 to len/2
•  » » 3 months ago, # ^ |   0 Any chain of U's can be broken up in fib(length) ways:Proof: if there are n of them: UU...U we can condition on whether to turn the first U into a W, or not: If we do, then it becomes W(U...U) (with n-2 U's) If we don't, then it becomes U(U...U) (with n-1 U's)Now each k-chain of U's or N's in the string has Fib(k) possible strings, so we multiply Fib(k) over all the k's
•  » » » 3 months ago, # ^ | ← Rev. 2 →   0 NiceBut how did you calculate the Fibonacci sequence?I was doing mod 1e9+7 during the calculation and I'm getting wrong answer on pretest 6
•  » » » 3 months ago, # ^ |   0 Any chain of U's can be broken up in fib(length) ways How did you come up with this intuition?
•  » » » » 3 months ago, # ^ |   0 For my case...I understood this by observation, I calculated the results for the first few lengths of chain and then realized the pattern :3
•  » » » » 3 months ago, # ^ | ← Rev. 3 →   0 Consider u as 1 and w as 2 , then how many possible combinations exist such that sum is n.Let n = 4uuuu = 1 + 1 + 1 + 1wuu = 2 + 1 + 1uwu = 1 + 2 + 1uuw = 1 + 1 + 2ww = 2 + 2There exists 5 ways which is nothing but fib[4].
•  » » » » 3 months ago, # ^ |   +1 I saw it in a book (Proofs That Really Count) in the first chapter. It explained that fibonacci numbers can be thought of as the number of ways to tile a 1xn grid using (unlimited) dominoes of size 1x2 and 1x1. There you condition on whether you place a rectangle or square domino in the leftmost place.
 » 3 months ago, # |   +15 what is test case 13 in D
 » 3 months ago, # |   +10 I thought this was an amazing round :D What lovely well framed questions
 » 3 months ago, # |   0 Does problem D using Prime Algorithm? I did it but got WA on test case 4. What is TC 4 :(
•  » » 3 months ago, # ^ |   +25 I think you mean the Prim Algorithm. As far as I know, yes.
•  » » » 3 months ago, # ^ |   +14 Yes, Prim Algorithm. Sadly, i still didn't solve it. After solving A, B, C for around 50 minutes. I came to problem D, the statement is so long and demotivate me a lot. After relaxing 10 mins, I decided to read the statement because I had 1 hour remaining time and the problem didn't hard as much as I think. If I started to solve it sooner, I would have more chances to debug. It's experiment for me. Very nice contest =)))
•  » » » » 3 months ago, # ^ |   +43 Yeah, I understand. I was puzzled too when I saw the super long statement. Just calm down and don't be afraid of those things. I believe you can do much better in the future. Good luck!
•  » » » » » 3 months ago, # ^ |   +13 Slightly off-topic, but I love comments like this for the example they set for the CF/CP community. :')
•  » » 3 months ago, # ^ |   0 I solved D with Prim's algo.
•  » » » 3 months ago, # ^ | ← Rev. 2 →   0 Dijkstra?I did using Dijkstra....But I guess the algorithm is similar XD
•  » » » » 3 months ago, # ^ |   +3 It's almost the same algorithm.
•  » » » » » 3 months ago, # ^ | ← Rev. 2 →   -11 -is-this-fft- Is this prim? Codevector indices; vector > edges; long long ans = 0; int tot = 0; while(!q.empty()) { pair > tp = q.top(); q.pop(); ans += tp.first; if(mark[tp.second.first]) continue; mark[tp.second.first] = 1; if(tp.second.second == -1) indices.push_back(tp.second.first); else edges.push_back(tp.second); for(int j = 0; j < n; j++) { if(mark[j]) continue; int i = tp.second.first; long long m = abs(x[j] - x[i]) + abs(y[j] - y[i]); long long cost2 = m * (k[j] + k[i]); if(cost2 < cost[j]) { q.push(make_pair(cost2, make_pair(j, i))); } } tot++; if(tot == n) break; } Edit: I need to re-order these two statements for AC. lol ans += tp.first; if(mark[tp.second.first]) continue; 
•  » » » » » » 3 months ago, # ^ |   0 It seems so
•  » » » » » » » 3 months ago, # ^ |   -8 hmm.. 13 is a devil's number i must say.test cases should be 1..12 and then 14..30
•  » » 3 months ago, # ^ |   0 Kruskal is fair enough
•  » » 3 months ago, # ^ |   0 Check out if you have used "long long int" instead of "int". I also got WA at test case 4, and this helped me :)
•  » » » 3 months ago, # ^ |   0 I used long long instead of int, but It didn't solve. Btw, what is the difference between long long and long long int? are they same?
•  » » » » 3 months ago, # ^ | ← Rev. 2 →   +1 Yes, they are identical.
•  » » » » 3 months ago, # ^ |   0 My situation is exactly the same as yours.Long long didn't save me.(•́ω•̀ ٥)
•  » » » » 3 months ago, # ^ |   0 Hey bro~I find a lil issue in my code,I defined a variable as int but it should be long long.Thus the program got overflow.Maybe you should check the type of each variable carefully.
•  » » » » » 3 months ago, # ^ |   0 Thanks bro, I definitely solve it again. I have just woken up.
•  » » » » » » 3 months ago, # ^ |   0 I lack of dummy city.
 » 3 months ago, # |   +8 What is pretest 13 of D? Wasted almost half hour :(
•  » » 3 months ago, # ^ | ← Rev. 2 →   +4 Try this: 4 1 1 1 2 1 3 1 4 100 101 102 2 2 2 2 100 Ans: 110
•  » » 3 months ago, # ^ |   0
 » 3 months ago, # |   +1 UwU
 » 3 months ago, # |   +19 dpforces
•  » » 3 months ago, # ^ |   +8 So true.
 » 3 months ago, # |   +7 How to solve F?
•  » » 3 months ago, # ^ |   +5 Dp with digits (in this case is binary digits).You have a+b = a xor b + a&b. Then a + b = a xor b if and only if a&b = 0.
•  » » 3 months ago, # ^ |   +10 I pre-solved it with digit dp. Let $f(pos, smaller_1, larger_1, smaller_2, larger_2)$ be the number of way to fill the first $pos$ binary bits such that [ the first number's prefix is already smaller than $r$ ], [ the first number's prefix is already larger than $l$ ], [ the second...], [ the second...] and their prefixes have no set bits in the same position so far. The transition is not hard to come up with. The answer is the sum of all entries in $f(0)$.
•  » » » 3 months ago, # ^ |   0 I am trying to understand your solution and transition. Could you please explain the transitions and the continue statements? I think this is a much generic approach. Thanks
•  » » » » 3 months ago, # ^ |   0 PMed you :)
•  » » » » » 3 months ago, # ^ |   0 Could you please forward the message to me too. I am also confused as to what would be the transitions. Thanks in advance.
•  » » » » » 3 months ago, # ^ |   0 Could you please forward the message to me too ))
 » 3 months ago, # |   0 I finally realized that it was problem E until I submitted my code(since mirror sites don't show the indices of problemsI fooled myself XDDDDDD
 » 3 months ago, # |   +16 Nice round. F is a fairly common problem btw. But it is still nice :)
 » 3 months ago, # |   0 Auto comment: topic has been updated by keima915 (previous revision, new revision, compare).
 » 3 months ago, # |   +3 Nice Contest and problems.But A was quite similar to this problem.
•  » » 3 months ago, # ^ |   +2 orz
 » 3 months ago, # | ← Rev. 3 →   +4 Find out why this gets WA8 (takes less than 5 seconds), i couldn't during the whole contest :DDDDDDDD SolutionTest: mnnn (should be impossible)Question #2: which lines cause the trouble? Answerfor i in range(1, len(s)): if s[i] in ["w", "m"]:This doesn't check the first character!:^)
•  » » 3 months ago, # ^ |   0 Same happened to me:(
•  » » 3 months ago, # ^ |   0 Answer to #2. Because the range of index starts from 0, not 1.
 » 3 months ago, # |   0 Ques.D) Shichikuji and Power Grid: In this question which concept and data structure are used. I think so Kruskal for the shortest path and DP for choosing the powerhouse or connection. Suggest or provide some explanation, I am a beginner for this type of question.
•  » » 3 months ago, # ^ | ← Rev. 2 →   +2 I used priority queue to solve. First, push the cost of setting plants at each city into priority queue along with city number. Then, start where cost of setting plant is smallest. Then push the cost making a connection from this city to every unelectrified city (along with city details) and push them into priority queue. Extract minimum cost (setting plant or making a connection) and go to step 3 (n-1 times).
•  » » » 3 months ago, # ^ |   +3 okay cool, a different approach
•  » » » 3 months ago, # ^ |   +12 it sounds like you just invented Prim algorithm lol
•  » » 3 months ago, # ^ |   0 My solution: Using Kruskal:Create all the possible edges and their weights(using formula in the statement). Sort the edges according to their weights.Suppose you are trying to connect the connected component U and the connected component V using the edges (x, y). Basically you have 2 options: Build a power station in a city in U and a power station in a city in V (Just pick the city with less cost). You don't have to build the edge (x, y) anymore. If you decide to build the edge (x, y) to connect U and V, then you have to build a power station in a city in the union of U and V. Just pick the smallest one. Just pick the optimal options for each edge (x, y) and add up the cost.
•  » » » 3 months ago, # ^ |   0 okay got it.
 » 3 months ago, # |   +1 In A I guessed from test cases that a and b needs to be coprime, and the submission worked, But I don't get why is this correct answer. For example a = 3, b = 7 there are infinitely many numbers which are coprime to 3 as well as 7, then aren't there infinite black numbers?
•  » » 3 months ago, # ^ |   +1 Check this: https://en.m.wikipedia.org/wiki/Coin_problem
•  » » 3 months ago, # ^ | ← Rev. 2 →   +4 A number $X$ will have color white iff $X$ can be written as a combination of $(a,b)$==> There exists $k_1,k_2>=0$ such that $X=k_1*a+k_2*b$.So the numbers $X$ having color black will be the ones such that that equation has no solutions. Since that's the Diophantine Equation(to which there's either an infinite number of solutions, or there are none), having no solutions means $X$ is not a multiple of $gcd(a,b)$.So if $gcd(a,b)=1$ then there's no such X.Else there will be many; infinitely many.
 » 3 months ago, # |   +23 D can be solved using a trick: create a virtual vertex, let's denote it as n + 1, then for every vertex connect it to (n + 1)th vertex with an edge having a weight equal to the vextex's c value. Then the problem becomes finding the MST of a given graph.
•  » » 3 months ago, # ^ |   +5 You don't need a virtual vertex for Prim's algo.
•  » » » 3 months ago, # ^ |   +6 I used Kruskal
•  » » 3 months ago, # ^ |   0 okay, you made this so easy for me by explaining
•  » » 3 months ago, # ^ |   +3 Woah !! Awesome trick.
•  » » 3 months ago, # ^ |   +1 can you please tell how you deduced that mst will work here, I mean it looks like baccktracking with unioin find to me.
 » 3 months ago, # |   +26 The competition was awesome !!
 » 3 months ago, # |   0 Maybe I'm the only one who solve B using dp and C using 2-dimension dp (I didn't think of Fibonacci or any stuffs related to it)
•  » » 3 months ago, # ^ |   +1 Do you use LuckyPaper ?
•  » » » 3 months ago, # ^ |   +2 ofcourse it's a certificate I got last year after participating a programming contest and now it's my mousepad
 » 3 months ago, # | ← Rev. 2 →   0 In problem C, I was using square free Fibonacci series. But, I got WA on pretest 9. Can someone help me?? My solution
•  » » 3 months ago, # ^ |   0 Square free Fibonacci series is wrong. You should use normal Fibonacci series.
•  » » » 3 months ago, # ^ |   0 Ok, I got my mistake. Thanks
•  » » 3 months ago, # ^ |   0 This might overflow since both are int:ans= (ans * k)%mod;
•  » » » 3 months ago, # ^ |   0 I have used #define for that
 » 3 months ago, # |   +40 Anyone notices that there seems to be no one (at least very very few people) that fails system test. Amazing contest!
•  » » 3 months ago, # ^ | ← Rev. 2 →   0 I failed in C , WA in tc 28 :/ Did I do anything wrong here? I am not able to figure outEdit: Forgot to add solution https://codeforces.com/contest/1245/submission/64023058
 » 3 months ago, # | ← Rev. 2 →   +23 Damn, these 4 ms help me become a candidate master!
 » 3 months ago, # |   0 I converted the problem C into "how many ways you can get a sum s using coins {1,2}"..then somehow didn't able to implement it in time...Its kind of sad
•  » » 3 months ago, # ^ |   0 That is a very nice solution.
•  » » » 3 months ago, # ^ |   +3 but I later figured it out that it will not work since,in counting number of ways a sum can be generated from fixed number of coins, order doesn't matters,but in our case order of selection will matter...eg. sum=3 can be generated from coin-sets {1,2} in two different ways {1,1,1} ans {1,2}(note that {1,2} and {2,1} are same) but the answer should be 3.It will convert to staircase problem counting number of ways to reach stair n if you can climb 1 or 2 stair at a time....correct me if I am wrong
•  » » » » 3 months ago, # ^ |   0 Yes, I don't think you are wrong
 » 3 months ago, # | ← Rev. 2 →   0 Can someone help me with solution of D.. Here's my submission 64039124My idea was to check if a node can be connected with any other node such that the cost for wiring is minimum and less than or equal to the cost to build a power station on that node. If such a node is available then construct an edge between them. Otherwise build a power station on that node.Lastly, if a component has no such node which has power station in it , then build a power station that requires minimum cost in one of the node of the component.. It is generating way too much minimum cost for test case 13. I couldnt find why
•  » » 3 months ago, # ^ |   +3 Try this: 3 1 1 2 2 1 3 1 10 12 2 3 1 Ans is 15 and not 17
•  » » » 3 months ago, # ^ | ← Rev. 2 →   +1 This solution also generates 15This is the output151122 33 1
•  » » 3 months ago, # ^ |   0 The correct answer is 18 3 1 3 2 1 1 4 10 10 3 1 1 8 
•  » » » 3 months ago, # ^ |   0 Thanks :)
 » 3 months ago, # |   0 A very balanced contest with strong cases , thank you :)
 » 3 months ago, # |   0 I am not able to see home,contest,gym option in my account? What happened..My homepage is not working
 » 3 months ago, # |   0 Great round! Thank you)
 » 3 months ago, # |   0 Is there any proof for the solution of 'C',I understand its solution but why this way only? Please anyone!
 » 3 months ago, # |   +3 I had following idea to D. Lets make minimum spanning tree of graph with edges $c(i, j) = (k_i+k_j) * d(i, j)$ for all $i , j$. Firstly lets add the cheapest plant. Then sort edges in non-increasing order and we will try to delete every edge. If we are considering edge $(x,y)$ let $c_1$ will be component with vert $x$ of tree without edge $(x, y)$ and $c_2$ will be component with vert $y$ of tree without edge $(x, y)$. Only one of this components has installed plant now. Let it be $c_2$ . Then find cost of the cheapest plant in $c_2$ and check if its better to add plant instead of edge from spanning tree. If its better to add plant, we delete edge $(x, y)$ and add plant. But, my solution got WA13. I will be grateful if you point out my mistake.
•  » » 3 months ago, # ^ |   0 Not entirely sure but could be that you are not using the "cost" of power plant while sorting, you are only using wiring cost while sorting? Both types of costs need to be consider. edges.pb(tii((k[i] + k[j]) * dist(i, j, coord), i, j)); SORT(edges); 
 » 3 months ago, # |   +15 Thanks keima915 !That was a good contest !
 » 3 months ago, # |   +37 However, she died when she was only in fifth grade so she is not smart enough for this.Wait, what codeforces?
•  » » 3 months ago, # ^ |   0 :D
•  » » 3 months ago, # ^ |   +2 Maybe it's reference to this character.
•  » » 3 months ago, # ^ |   0 Honestly, didn't read this part until you pointed out, XD...
 » 3 months ago, # |   0 Has anyone solved D using dynamic programming?
 » 3 months ago, # |   0 Another solution for D is the O(n^2) version of Prim's algorithm which works better on a dense graph. It doesn't need extra dummy nodes either. Is it the most efficient solution?I solved D in this way after the round, but my implementation was slower than I expected.
 » 3 months ago, # |   0 Can anyone help me with problem D. I sumbited the same code twice, and in the constest y got TLE, but after resumbitting i got AC. https://codeforces.com/contest/1245/submission/64045463 https://codeforces.com/contest/1245/submission/64035229
•  » » 3 months ago, # ^ |   +13 Your AC code was just 4 ms away from TLE. It just got lucky. The execution time of the same code can differ by a few ms in different submissions. That is the reason behind TLE. Your code was not just lucky enough to get AC in contest time!
 » 3 months ago, # |   +4 D is very much similar to this problem : https://vjudge.net/problem/LightOJ-1059
 » 3 months ago, # |   0 Although the contest was very well written and prepared, but still after seeing the next contest, I am like — "Finally, a div. 3 round...., Yay!"
 » 3 months ago, # | ← Rev. 2 →   +3 Hello my solution to problem D is either bugged or incorrect. With bugs I can cope but I worry it might be simply incorrect. It fails to pass test 13 (wrong answer).My idea:Firstly, take each city and make network out of it, making total n networks. Assume that every network doesn't have electricity supplied to it. while (there exists network that doesnt have electricity supplied) { take any network P that doesnt have electricity supplied if (its cheaper to build plant inside P, than to connect P to any other network (OR) its impossible to connect P to any other network (there are noo other networks)) { build plant (cheapest possible amongst members in P) inside P supplying electricity to it } else { build connection between P andd other, closest possible network (closest = cheapest road) merging two networks into one } } I'm not worried about time complexity as above can be implemented in a fairly fast way. Just whether this should work or not.Thanks for help in advance.
•  » » 3 months ago, # ^ |   +8 Hello :)I didn't read your method, all I could do to help was stresstest, and I found a case where your code(I used the last submission) fails compared to my accepted solution. test case425 1123 1131 1130 2541 43 44 48 3 3 4 8 your answer14531 3 4 11 2 correct answer14321 4 21 21 3
•  » » » 3 months ago, # ^ | ← Rev. 2 →   0 Thanks!Turns out my solution was bugged :)
 » 3 months ago, # |   -19 The worst round I've ever solved...
 » 3 months ago, # |   0 How are you supposed to solve D using Kruskal's Algorithm?When I sorted the 2,000,000 edges, I got TLE on Test 7. Is this only because I used Java, or is Kruskal too slow in general for this problem?
•  » » 3 months ago, # ^ |   0 I've heard that inbuilt sorting function in java is sometimes slow(maybe it is a quick sort variant),i do not know otherwise...
•  » » » 3 months ago, # ^ |   0 I have a sort method that randomizes the numbers being sorted first, so that it is immune to the Quicksort TLE. I simply believe that the time constraints are a little too tough for Java, at least using Kruskal.I used Prim's algorithm to pass the test case in just 202 MS though.
 » 3 months ago, # |   0 great job I love this round too
 » 3 months ago, # |   0 Can someone help me for problem B? I cannot find out where I am wrong? 64097713
•  » » 3 months ago, # ^ |   0 The way you find the optimal sequence of moves(your string 'alice') in the case of YES is wrong.Try this case to find what you did wrong. test case13 2 1 0SPS correct answerYESRPR
•  » » » 3 months ago, # ^ |   0 Got it.Thank you very much.