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

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

1932A - Шипы и монеты

Идея: denk

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

1932B - Календарь Чая

Идея: Vladosiya

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

1932C - LR-остатки

Идея: MikeMirzayanov

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

1932D - Карточная игра

Идея: goncharovmike

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

1932E - Финальный отсчёт

Идея: step_by_step

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

1932F - Кормление кошек

Идея: denk

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

1932G - Перемещающиеся платформы

Идея: denk

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

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

Tutorial after 3 days. Why?

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

In F, we consider all values from 1 to N. If we only checked points that are either start of end of an interval, then it gives WA. Why could that be?

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

Here's a derivation to the solution to E.

Let the initial string/number $$$a_na_{n-1}...a_1$$$.

A change of:-

$$$n$$$ digits occurs $$$a_n$$$ times.

$$$n-1$$$ digits occurs $$$9*a_n + a_{n-1}$$$ times.

$$$n-2$$$ digits occurs $$$9*(a_na_{n-1})+a_{n-2}$$$ times.

Thus, the final answer is:-

$$$= n*a_n+(n-1)*(9*a_n + a_{n-1})+(n-2)*(9*a_na_{n-1}+a_{n-2})+...$$$

$$$= n*a_n+(n-1)*(a_na_{n-1} - a_n)+(n-2)*(a_na_{n-1}a_{n-2}-a_na_{n-1})+...$$$

$$$= n*a_n-(n-1)*a_n+(n-1)*a_na_{n-1}-(n-2)*a_na_{n-1}+(n-2)*a_na_{n-1}a_{n-2}-...$$$

$$$= a_n+a_na_{n-1}+a_na_{n-1}a_{n-2}+...+a_na_{n-1}...a_1$$$

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

Thanks for very fast editorial

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

For F, what if the range of intervals was [1, 1e9]. how can we solve this question then?

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

In problem G,my code got a "Wrong Answer" on test 2. Can anyone give me a hack? Many thanks.

https://mirror.codeforces.com/contest/1932/submission/247682595

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

I like how they put a "2012" reference in the last test case of problem B.

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

Alternative (linear) solution for F:

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

Correction in third last line, in editorial of G..

k′=b′−1a′modH --> k′=b′−1a′modH′

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

Question regarding Problem G.

The original equation is like this,

$$$ xb + yH = a $$$

By using extended Eucledian algorithm, we can find a particular solution $$$(x_o, y_o)$$$,

$$$ x_o b + y_o H = GCD(b, H) $$$

Multiply $$$\frac{a}{GCD(b, H)}$$$ on both sides, so that we can get the original equation,

$$$ x_o \frac{a}{GCD(b, H)} b + y_o \frac{a}{GCD(b, H)} H = a $$$

However this is just a particular solution, the general solution should be like this,

$$$ (x_o \frac{a}{GCD(b, H)} + t H) b + (y_o \frac{a}{GCD(b, H)} - tb) H = a $$$

Now all we need to do is to find the smallest non-negative integer solution for this $$$(x_o \frac{a}{GCD(b, H)} + t H)$$$

However in the editorial code,

x *= a / dd
x %= H / dd

What is the reason of doing this and why is H/dd was used instead of H. Are there any mistake in my derivation?

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

In problem G, why do we take x modulo (H / dd) ?

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

    Using 'auto [dd,x,y] = eucl(b,H)', we got one possible solution to the equation — 'xb+yH=dd' (here (dd is the gcd). Now, we multiply 'a/dd' to the above equation to get — '(x*a/dd)*b + (y*a/dd)*H = a'. Now we have one solution {x0,y0} — {(x*a/dd),(y*a/dd)} to the equation but we want the one having smallest positive x0 value. general solution for the above equation would be — {x,y} = {x0 + k*(H/dd) , y0 — k*(b/dd) }. so the samlest possible 'x' would be 'x%(H/dd)' . check out this for more clarification — https://cp-algorithms.com/algebra/linear-diophantine-equation.html

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

spent an hour thinking how can i store remainders,,, never thought of a reverse logic,

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

can anybody explain C to me as i am unable to understand the editorial..

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

Without using the multiset approach for F just stores the maximum r for each step. We can do this by assigning the starting point of any [L, R] as step[L] = max(step[L], R) and then take prefix max. Here is the submission.337728368