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

Автор awoo, история, 9 лет назад, По-русски
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Разбор задач Educational Codeforces Round 26
  • Проголосовать: нравится
  • +33
  • Проголосовать: не нравится

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

contribution of a0[i] in ar[n] is
Using this and binary search on answer , you can solve this in NlogK

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

Is there a name for the type of function in G? It's some combination of Sigmoid and ReLU, but I couldn't find it's name...

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

В задаче G можно обойтись без персистетности написав, например, sqrt-декомпозицию.

В каждом блоке мы можем хранить для каждого xi два значения: ai и bi. Чтобы их посчитать, мы можем использовать технику сканирующей прямой. Чтобы получить ответ для блока, мы для x бинарным поиском найдем наибольший i такой, что xi  ≤  x, тогда ответ для блока будет равен ai · x  +  bi. Чтобы получить ответ на запрос, нам нужно просуммировать ответы для блоков, которые целиком входят в [l, r], а для оставшихся fi пройдемся в тупую и прибавим к ответу.

Асимптотика:

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

Can anyone help me in understanding the rationale behind choosing the way the dp is being done? Why the 3D approach? How was the logic arrived at? Is there another, more intuitive way? Thanks!

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

Could somebody explain the way we store all possible summary powers of 5 in dp array? There can be i * log5(1018) variants, and if we will iterate through them all n2 times (including non-existing), it will waste too much memory ..

I tried to use map to exclude non-existing variants, but n3 * log(n * log5(1018)) got TL: http://codeforces.me/contest/837/submission/29189656

Thanks in advance :)

UPD. Finally got it. We do not need to store current position, only 2 last lays needed (dp[2][200][200 * log5(1018)])

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

My lame F solution that passes:

n > 3 is sufficient to pass the naive approach (after zero prefix deletion). So we should handle n==2 and n==3. For n==2 we can write linear O(1) equation on k, and for n==3 there is quadratic equation on k which can be solved in O(1) or O(log 10^18) using binsearch.

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

On Problem G, I set up four President Tree and the Time Limit seems too tight for me 29192449, maybe I will be hacked sooner or later :)

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

Почему в задаче D, круглость числа — это минимум из степеней 2 и 5 в числе.

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

    У нас есть ответ A. Пусть A = Q * 5x * 2y, где Q не делится ни на 5 ни на 2. Преобразовав получим A = Q * 10min(x, y) * 5x - min(x, y) * 2y - min(x, y).

    Количество нулей в конце десятичной записи числа — показатель максимальной степени десятки, которая является делителем этого числа. В нашем случае это min(x, y)

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

Simpler solution to Problem E. Without prime factorization. Let d = gcd(a, b); It can be proved that f(a,b) = f(a/d, b/d); if a is prime, then answer is (b % a + b/a); Then the result can be recursively computed. My solution

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

. can any1 prove it ; If we denote old value of gcd(x, y) by g, the new value of gcd(x, y) will be divisible by some k·g, where k is a prime divisor of x.

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

For Problem F - In fact, you can brute force the prefix sums if the array is of size at least 4. In case of size 2 it's super simple. And lastly, in case of size 3 it can be solved mathematically.

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

Regarding problem D, does this sentence: "the first dimension should be stored in two layers and recalced on the fly" mean that :

for every position i you only need the result of i-1 so no need to store the results corresponding to positions earlier than i-1 ?

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

Anyone can help me to find what's wrong with my solution for problem D? http://codeforces.me/contest/837/submission/29282743

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

can anyone elaborate this line?

Let dp[i][j][l] be the maximum amount of twos we can collect by checking first i numbers, taking j of them with total power of five equal to l. It is usually called "the knapsack problem".

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

    For dp[i][j][l] = n,

    • n is the greatest integer that satisfies 2^n | (the product of the numbers in the selected subset)

    • l is the greatest integer that satisfies 5^l | (the product of the numbers in the selected subset)

    • j is the number of numbers selected from the set (or the size of the subset selected)

    • i is the number of numbers considered

    eg. If dp[3][2][2] = 1, (looking at the first 3 numbers given, selecting exactly two such that 5^2 is the greatest power of 5 that divides the product), 2^1 is the greatest power of 2 that divides the product.

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

Task E

Can anybody proove that k in new gcd will be PRIME (that there is no better non-prime k)?

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

F has a much simpler solution using contribution technique i believe.

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

How to solve problem D using top-down approach?

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

How to solve D using recursive dp? Is it possible? I wrote the recursive function to compute the number of twos but it is very confusing how to extract the solution out of it.