By Vladosiya, history, 2 years ago, translation,

1675A - Еда для животных

Idea: MikeMirzayanov

Tutorial
Solution

1675B - Сделай возрастающую

Idea: MikeMirzayanov

Tutorial
Solution

1675C - Детективная задача

Idea: Gol_D

Tutorial
Solution

1675D - Вертикальные пути

Idea: MikeMirzayanov

Tutorial
Solution

1675E - Замени на предыдущий, минимизируй

Idea: myav

Tutorial
Solution

1675F - Влад и отложенные дела

Tutorial
Solution

1675G - Сортировка блинчиков

Tutorial
Solution
• +25

| Write comment?
 » 2 years ago, # |   +19 With respect to the F problem, another (maybe simpler?) explanation: hang the tree from x (or y, it's equivalent) iteratively remove all leaves that are not in a or [x, y], we'll end up with only nodes that we'll visit all edges from the resulting graph need to be traversed twice (back and forth), except the ones connecting x to y if the graph after step 2 has n edges, the solution is 2 * (n — 1) — depth[y]
•  » » 23 months ago, # ^ |   0 Can you please explain why answer can't be 2*(no of edges) — depth[y].Link to My submission : LinkSorry If I misunderstood your approach
•  » » » 23 months ago, # ^ |   0 It is exactly that, after removing from the graph all the leaves that aren't in a. You can have a look at my submission: https://codeforces.com/contest/1675/submission/156053555
•  » » 9 months ago, # ^ |   0 The 3rd step seems intuitive enough with just a few examples, but I can't concretely come up with proof for the third step. Can you explain why this is always the case?
•  » » 7 weeks ago, # ^ |   0 Brilliant! Thank You!
 » 2 years ago, # | ← Rev. 2 →   +3 In case someone is interested, I made video Solutions for D-F
•  » » 2 years ago, # ^ |   +4 Video Solution for G
•  » » » 2 years ago, # ^ |   0 sharmaharisam epsilon_573 you guys should do a collab, since one has uploaded d, e, f and the other has uploaded g. (YouTube collab, not contest collab xD).
•  » » » » 2 years ago, # ^ | ← Rev. 2 →   0 Actually I was recording A-F last night, but E was so tricky to explain intuitively... I just skipped the video altogether :p
 » 2 years ago, # | ← Rev. 2 →   +1 .
 » 2 years ago, # |   +7 Maybe C is simpler if we do3 Cases: It is a '?' increment counter it is a 0, return counter + 1 it is a 1, reset the counter and set it to 1.
 » 2 years ago, # |   0 Can anyone explain what does int lend = min(j, k - a[i]); mean, in problem G?
•  » » 2 years ago, # ^ |   +3 It's the number of pancakes, we need to take from dishes with bigger index. k — a[i] is how many is missing to get sum = k but we can't need more than j, because all pancakes on previous dishes are placed, so it's min(j, k — a[i]).
 » 2 years ago, # |   0 Question D，why I always got tle if i look for the path from up to bottom?
•  » » 2 years ago, # ^ |   0 and also tle with the tutorial's method
 » 2 years ago, # |   0 My $O(n * m^3)$ for G almost got TLE. Submission
 » 2 years ago, # | ← Rev. 2 →   +4 Any resources or similar problems to better understand G? Still confused by just reading editorial.
 » 2 years ago, # |   +3 Can anyone explain the solution of the problem G-Sorting Pancakes??
•  » » 2 years ago, # ^ |   +2 In G, intuitively we see that a dp solution will work. If we want to put some pancakes on the ith dish, we need to have the same or more pancakes on the previous dish. To determine what can be put down later, we need to know how many pancakes we have put down previously. Hence, we need to take note of 1) how many pancakes we put down on the ith dish, and 2) how many pancakes we have put down in total. These will form our state. Hence we can have dp[i][number of pancakes on ith dish][number of pancakes put down in total] to describe our solution. The number of states for dp[n][m][m] is n * m * m which is 250 * 250 * 250 which is small enough.To transition to dp[i][j][k], we come from a previous state with fewer total pancakes. But the previous state's number of pancakes must be more. So we have dp[i-1][j2>=j][k-j] -> dp[i][j][k]. So, dp[i][j][k] = min(dp[i][j][k], dp[i-1][j2][k-j] + some transition value) for all j2>=j. The transition value (referred to as "add" in the editorial) is the number of moves required to go from a "pancake configuration" of having k-j pancakes in the first i-1 plates, to the same configuration but with exactly j pancakes on the ith plate. I don't know how people calculate these transition values elegantly. I had a greedy and incredibly messy way to calculate these.Finally, the answer is the minimum value for dp[n — 1][j][m], for 0<=j<=m. I hope this helps.You may refer to my solution 156195983 but it is in python, with the differences of me reversing a to solve for increasing pancakes, and I switched the definitions for j and k. So my definition is dp[i][prefix sum of pancakes up to i][number of pancakes on i].
•  » » » 23 months ago, # ^ |   0 can u elaborate why the dp is : dp[i][number of pancakes on ith dish][number of pancakes put down in total] and why not dp[i][number of pancakes put down in total][number of pancakes on ith dish] ? Can we imagine this as a 3D matrix? If so, then what do the row, column and height of this matrix implicate?
•  » » » » 23 months ago, # ^ |   0 Both ways work. I used the latter which is dp[i][number of pancakes put down in total][number of pancakes on ith dish] in my actual solution. But the solution used in the editorial uses the former which is dp[i][number of pancakes on ith dish][number of pancakes put down in total].I will also discourage you from visualizing dp matrices spatially because it is very difficult and unnecessary. The important thing for doing dp is to have a firm understanding of the states, their transitions and their edge/boundary cases.
•  » » » » » 23 months ago, # ^ |   +3 thank you for ur fast response sir :D
 » 23 months ago, # |   0 Can someone explain the solution for problem E. Tutorial is somewhat complicated to understand.
 » 23 months ago, # |   0 Can you please explain why in the task g dp transitions are d[i][last][k] = d[i-1][last][k-last] does it means that last = j, instead of last >= j?
•  » » 23 months ago, # ^ |   +1 Got it
 » 23 months ago, # | ← Rev. 2 →   0 I solved problem F with dfs, dp, and LCA+binary lifting. A lot more stuff than needed lol156882408 Warning: Code is quite messy and I haven't commented. Enter at your own peril.