Блог пользователя Vladosiya

Автор Vladosiya, история, 2 года назад, По-русски

1907A - Ладья

Идея: pashka

Разбор
Решение

1907B - YetnotherrokenKeoard

Идея: pashka, MikeMirzayanov

Разбор
Решение

1907C - Удаление некрасивых пар

Идея: Vladosiya

Разбор
Решение

1907D - Прыжки по отрезкам

Идея: MikeMirzayanov, Vladosiya

Разбор
Решение

1907E - Хорошие тройки

Идея: pashka

Разбор
Решение

1907F - Сдвиг и разворот

Идея: pashka

Разбор
Решение

1907G - Освещение

Идея: pashka

Разбор
Решение
Разбор задач Codeforces Round 913 (Div. 3)
  • Проголосовать: нравится
  • +27
  • Проголосовать: не нравится

»
2 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится +27 Проголосовать: не нравится

It would be better if you added formatting for the solution to Problem F.

UPD: Thanks

»
2 года назад, скрыть # |
Rev. 4  
Проголосовать: нравится +22 Проголосовать: не нравится

In E, we can also notice that the answer to each digit x(0-9) is simply ((x+1)*(x+2))/2.

Explanation 1: Let, x be split as x=a+b+c. If a=x, b+c=0; this will generate one combination->(x,0,0). If a=x-1, b+c=1; this will generate two combinations->(x-1,0,1) and (x-1,1,0).Similarly you can notice that the total combinations for digit x= 1+2+3+..+x+x+1= ((x+1)*(x+2))/2. So, no need to use the loops to calculate this.

Explanation 2(Suggested by my brother): The combinatorics formula to distribute x as a sum of k non-negative numbers is C(n+k-1,k-1) which here transforms to C(x+3-1,3-1)=C(x+2,2)=((x+1)*(x+2))/2.

Or, you could have just figured this out by looking at the test cases.

»
2 года назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Video Editorial For Problems A,B,C,D,E,F,G._

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

wasn't able to participate in this contest, but the problems were very good, I think. although G does feel like it reduces down to just applying a standard graph algorithm, no?

»
2 года назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

Video solution for Chinese:

BiliBili

»
2 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится +29 Проголосовать: не нравится
My DP solution for E - Good Triples
»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone please explain why this code for G is giving TLE at test case 25. I am following a bit different approach to encounter bulbs in cycle but it is O(N) only. This is my submission link -> https://mirror.codeforces.com/contest/1907/submission/236036536

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone explain F,i don't understand tutorial at all.

»
2 года назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

In C, how do you prove that if no character appears more than floor(n/2) times, we can always achieve n%2 length of the final string? Please help.

»
2 года назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

коротко и ясно

»
2 года назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Nearly 24 hours have passed, and the rating still doesn't change?

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is the reason why editorial's check function for Binary Search works trivial? Because after x steps, if the intersection with the segment is non empty => I have one sequence of steps that lands me after x steps inside that interval. It does not ensure that those steps are consistent with the last x-1 regions right? (It should since the editorial is right, but I don't see how we can prove it.)

  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    Consider the segment after x steps, if you can find one with intersection. For all points inside this segment there is a point in the last segment you could have reached it from. In other words you can pick any point in the current valid segment, and there is a point in the last segment from where you could reach this. You can continue this reasoning to the first segment. I agree, this is not that trivial to see.

»
2 года назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

Thank you for such a wonderful round pashka, Vladosiya, MikeMirzayanov. I will be looking forward to a new and interesting round from you.

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

G is very similar to https://mirror.codeforces.com/problemset/problem/1872/F. Just a little addition that the nodes now have states attached to them.

»
2 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Hi, can anyone tell me why this is TLE in Python but AC in C++?

Python: 236125120 it is TLE without the fastIO line as well.

C++: 236125273

I am having an identity crisis.

*accidentally posted the comment in Russian, my apologies for the spam

»
2 года назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

Is this Tutorial written for those who don't need it?

No proof, No explanation, Only conclusion. Oh, yes, I completely understood

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

236178810 Can Anyone tell me what is wrong in the mentioned code.

»
2 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится +16 Проголосовать: не нравится

The problems are great, but I feel that the editorial is written rather poorly.

Here is a (hopefully) more intuitive editorial of problem F -

Let us consider the inverse of the operations given in the original problem, for the sake of better understanding.
Given a sorted array in non-decreasing order $$$s$$$, you can perform two operations:
- Shift Inverse: move the first element of the array to the last place, and shift all other elements to the left, so you get the array $$$s_2,s_3,...,s_n,s_1$$$.
- Reverse: reverse the whole array, so you get the array $$$s_n,s_{n-1},...,s_1$$$.

By observation, we realize, that there are three types of arrays that arise when we perform the above operations on some sorted array $$$s$$$:
i) The most basic of it is the reverse of $$$s$$$ — the array $$$s_n,s_{n-1},...,s_1$$$.
ii) An array of the form $$$s_k,s_{k+1},...,s_n,s_1,s_2,...,s_{k-1}$$$, $$$1 \lt k \le n$$$.
iii) An array of the form $$$s_k,s_{k-1},...,s_1,s_n,s_{n-1},...,s_{k+1}$$$, $$$1 \le k \lt n$$$.

Thus, we can break down the original problem into the following cases:

  1. If $$$a$$$ is sorted — No moves required, answer is $$$0$$$.

  2. If $$$a$$$ is sorted in reverse order — reversing the array solves it, answer is $$$1$$$.

  3. If $$$a$$$ is of the form presented in case ii) above —
    Let us break the array into two parts: the first part being the part of $$$a$$$ corresponding to $$$s_k,s_{k+1},...,s_n$$$ (let us call this part $$$F$$$) and the second part being the part of $$$a$$$ corresponding to $$$s_1,s_2,...,s_{k-1}$$$ (let us call this part $$$S$$$). We can solve this in two ways —
    (a) perform the 'Shift' operation on all elements of $$$S$$$. So total number of moves = $$$|S|$$$.
    (b) perform the 'Reverse' operation on $$$a$$$, perform 'Shift' operation on all elements of $$$F$$$, and then perform the 'Reverse' operation again. So total number of moves = $$$|F|+2$$$.
    We take the minimum of (a) and (b), and that is our answer.

  4. If $$$a$$$ is of the form presented in case iii) above —
    Let us break the array into two parts: the first part being the part of $$$a$$$ corresponding to $$$s_k,s_{k-1},...,s_1$$$ (let us call this part $$$F$$$) and the second part being the part of $$$a$$$ corresponding to $$$s_n,s_{n-1},...,s_{k+1}$$$ (let us call this part $$$S$$$). We can solve this in two ways —
    (a) perform the 'Shift' operation on all elements of $$$S$$$, and then perform the 'Reverse' operation. So total number of moves = $$$|S|+1$$$.
    (b) perform the 'Reverse' operation on $$$a$$$ and then perform 'Shift' operation on all elements of $$$F$$$. So total number of moves = $$$|F|+1$$$.
    We take the minimum of (a) and (b), and that is our answer.

  5. If $$$a$$$ is neither of the cases presented above, then the answer is $$$-1$$$.

C++ code for reference.

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

[DOUBT][PROBLEM G] — > can someone explain how to find minimum number of operations to turn off all turned on lights in the cycle? firstly, we will remove/turn off all nodes with in-degree=0 and will keep on removing till we find the cycle. I am struck after this point.

  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится +2 Проголосовать: не нравится

    Find any light that is on in the cycle. There are only two ways for it too be turned off — either you directly flip it's switch or you flip the switch of the previous node in the cycle. Once you've chosen the starting node to start flipping you can move through the greedily flipping any lights that are on. Calculate the number of flips for both starting nodes and choose the smaller.

»
2 года назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

The editorials are very hard to understand, specially for E, F and G. :)

»
2 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

:D

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In Problem E. 1907E — Good Triples Can someone please tell the proof for:

"A triplet is considered good only if each digit of the number n was obtained without carrying over during addition."

This is a good observation, but how can I prove such information or approach it at least?

»
2 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

There exists a hashing solution to problem F.

You can save two hash values , one for the sorted non-decreasing array and the other for the sorted non-increasing array.

Then, you can try doing the operations on the original array or on the reverse of it ( with additional cost of one operation). Doing the operation on an element which is the last in array is simply subtracting the element from the current hash, dividing by base and adding this value * base ^ (n-1).

Then, the first moment where the hashes are equal , we have found an answer to minimize over it and stop doing operations.

Link to submission: https://mirror.codeforces.com/contest/1907/submission/236598692.

P.S I found this solution more understandable than what is written in the tutorial.

»
22 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

If anyone want solution for question F , i have explained in comments in simple words 273078914