### Gol_D's blog

By Gol_D, history, 10 months ago,

1660A - Vasya and Coins

Idea: MikeMirzayanov

Tutorial
Solution

Tutorial
Solution

1660C - Get an Even String

Idea: MikeMirzayanov

Tutorial
Solution

1660D - Maximum Product Strikes Back

Idea: Aris

Tutorial
Solution

1660E - Matrix and Shifts

Idea: myav, MikeMirzayanov

Tutorial
Solution

1660F1 - Promising String (easy version)

Idea: MikeMirzayanov

Tutorial
Solution

1660F2 - Promising String (hard version)

Idea: MikeMirzayanov

Tutorial
Solution

• +50

 » 10 months ago, # |   +6 If you are/were getting a WA/RE verdict on problems from this contest, you can get the smallest possible counter example for your submission on cfstress.com. To do that, click on the relevant problem's link below, add your submission ID, and edit the table to increase/decrease the constraints.I've also added a new feature to view progress of your judgement in near real-time. (For example, the current state of your ticket, how many inputs were evaluated, etc). If you are not able to find a counter example even after changing the parameters, reply to this thread, mentioning the contest_id, problem_index and submission_id.
 » 10 months ago, # |   +4 my divide and conquer solution for fhttps://codeforces.com/contest/1660/submission/152497191
•  » » 10 months ago, # ^ |   0 Can you explain ur solution
•  » » » 10 months ago, # ^ |   0 in problem I made simple observation that whenever number of negative is greaterlet say r = number of negative in subarray — number of pos in subarrayif r >0 and r%3 == 0 then subarray will be promissing I used divide and conquer to calculate those subarray
 » 10 months ago, # | ← Rev. 2 →   +6 There is a solution in the f2 order_set or fenw_tree.This is awesome
 » 10 months ago, # |   0 thanks for explanations
 » 10 months ago, # |   0 In B Can someone please explain why 6 1 1 1 1 1 5 will give no in this case we eat candies like index 6, index 5 , index 6, index 4, index 6, index 3 , index 6 , index 2 , index 6 ,index 1.
•  » » 10 months ago, # ^ |   0 Give attention to this line, "Vlad decided to eat exactly one candy every time, choosing any of the candies of a type that is currently the most frequent (if there are several such types, he can choose any of them)." In your case, the most frequent one is 5 and when he eats one candy, the most frequent type is again the last one because its count is 4 and is highest. And Vlad also don't want to eat same candies in a row. That is why this case will give a NO.
 » 10 months ago, # |   0 Can anyone please point out for me the difference between these two submissions:152864441(I used vector and got WA)152864364 (I used array and got AC)Thanks in advance!!!
•  » » 10 months ago, # ^ |   0 Most likely this is due to integer overflow with arrays.
•  » » » 10 months ago, # ^ |   0 Can you elaborate more for me ? I'm still confused. Thank you very much!
•  » » » » 10 months ago, # ^ | ← Rev. 3 →   0 Look at expression in line 21:if((n == 1 && vec[0] > 1) || (vec[n — 1] — vec[n — 2] > 1))The condition behind the OR doesn't check for vector size, so for n == 1, then you are evaluating this: (vec[0] — vec[-1] > 1)Imagine this input:111Then:(n == 1 && vec[0] > 1) || (vec[0] — vec[-1] > 1)(1 == 1 && 1 > 1) || (1 — vec[-1] > 1)(true && false) || (1 — vec[-1] > 1)false || (1 — ?? > 1)So basically you are accessing vec[-1]. Depending on the value in that "illegal" memory position, it may be true or false. Same happens for arr[-1], but you just go lucky there with the memory value there at the time of the submit.
•  » » » » » 10 months ago, # ^ |   0 Wow, now I get that! Thanks very much!
 » 10 months ago, # |   0 Can someone check my I get a memory limit to exceed the error in the c problem https://codeforces.com/contest/1660/submission/153739220
 » 9 months ago, # | ← Rev. 2 →   0 Does the solution of F1 take into account the adjacent situation?
 » 8 months ago, # |   0 How can I solve C. Get an Even String with dp ?
•  » » 7 months ago, # ^ | ← Rev. 2 →   0 To solve 1660C with DP we should start by finding the recursive solution: for each i in the strings there are 2 options: I either remove the current element, or I remove elements until I reach the next occurrence of this character in the string (if there is any). We recur on both options and take the minimum result.The naive approach to finding out how many elements are until current element and next occurrence of character is a simple linear scan. We can speed it up by a LOT by first scanning the string and then storing the positions of the characters in the string in a vector> pos(26), where index stores the character type, and the elements in the set store the indexes where this element occurs.After that simple (but most likely necessary) optimization, we can notice one thing: if I happen to be in the same index again, the best solution is going to be the same! So I simply store it in a memo vector.This is my submission for additional clarity: 163585297It's gonna be pretty simple translating it to a simple iterative bottom-up approach! This exercise is left for you.
 » 7 months ago, # | ← Rev. 2 →   0 I think there is a mistake in tutorial for problem C. Instead of used it should be prev.
 » 5 weeks ago, # | ← Rev. 3 →   0 187127635 Problem D: Can someone explains me, Why i am getting WA with this??
•  » » 5 weeks ago, # ^ |   0 Take a look at Ticket 16616 from CF Stress for a counter example.