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

Автор awoo, история, 6 лет назад, По-русски

1476A - Сумма, кратная K

Идея: vovuh

Разбор
Решение (adedalic)

1476B - Инфляция

Идея: adedalic

Разбор
Решение (adedalic)

1476C - Наидлиннейший простой цикл

Идея: adedalic

Разбор
Решение (adedalic)

1476D - Путешествие

Идея: BledDest

Разбор
Решение 1 (BledDest)
Решение 2 (BledDest)

1476E - Сопоставление шаблонов

Идея: BledDest

Разбор
Решение 1 (awoo)
Решение 2 (awoo)

1476F - Фонари

Идея: BledDest

Разбор
Решение (BledDest)

1476G - Минимальная разница

Идея: Neon

Разбор
Решение (Neon)
  • Проголосовать: нравится
  • +143
  • Проголосовать: не нравится

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

Problem E was beautiful! Thanks :D

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

Finally a contest with less ad-hoc problems!

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

Finally a contest with less ad-hoc!

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

contest is good but statement of E was awful

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

In problem C , How the value of the following test case will be 6? please explain..

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

I think Problem D is simpler to use the Disjoint-set. Am I right?

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

This was a very nice contest after a while. Kudos to the authors, each and every problem in the contest that I solved / up-solved taught me something new. Hope for more such rounds :)

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

Can someone help me figure out the error of code for submission below? My Code Here is my code for problem F. It gets wrong answer on test 5, case 1259. However, I can't get that sample.

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

Can Anyone tell me how to solve question D recursively and doing memoization?

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

For B, can anyone explain why there's a k-1 added to 100ll * p[i] - k * pSum?

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

    It is basically done to take ceil of the value.

    Let me make it more clear — Ceil(a/b) == (a+(b-1))/b

    You can check this by taking two cases -

    1. a = k*b. Both functions return k

    2. a = k*b + x (0<x<b). Both functions return k+1;

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

      but in editorial he didn't mention the ceil thing i understand it from the code but i dont understand the purpose of it, if u can explain please

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

        It is mentioned in the editorial that -

        $$$x \ge \left\lceil \frac{100 \cdot p_j - k \cdot (p_0 + \dots + p_{j - 1})}{k} \right\rceil$$$

        Notice the bracket, that is for denoting ceil function.

        Now the next question is why do we even need that — because x is a non negative integer and right hand side acc. to maths will return a floating value (which may not be integer).

        Let's take an example — You know x is an integer and after solving RHS you get -

        $$$x \geq 1.2 $$$

        So definitely you know you should pick next integer (ceil value) as answer i.e. x = 2.

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

A constant optimization for 1476G - Минимальная разница -- observing that the upper bound of value $$$c$$$ always equals to the lower bound of $$$(c + 1)$$$, we can store only the lower bounds (but not both as in the model solution),

You can see my submission 106048247 for the detail.

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

For E, why can't I topsort it?

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

In E you can also find a match converting the string to integer. The number of possible strings is $$$27^k$$$, so every pattern can be indexed.

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

Question for problem E

Input

  • 4 4 4
  • aaaa
  • aaaa
  • aaaa
  • aaaa
  • aaaa 2
  • aaaa 2
  • aaaa 2
  • aaaa 2

The solution's output is "NO", but I think 2 1 3 4 is right, do I understand the problem wrong?

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

In the first problem, I did the same thing with ceil function but it threw wrong answer...How is it possible to get the correct answer by just using ceil in a different mathematical way as shown in tutorial??

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

Problem B : Inflation.

int n =sc.nextInt(); double k =sc.nextDouble();

double a[] = new double[n];

        for(int i=0;i<n;i++)
            a[i]=sc.nextDouble();

        double denominator = 0, dummy=0;

        for(int i=1;i<n;i++)
        {
            double numerator = a[i];
            denominator = denominator+a[i-1];
            dummy = dummy+a[i-1];
            if((numerator/denominator)*100<=k);
            else
            {
                double required = (numerator/k)*100 - denominator;

                denominator =  denominator + Math.ceil(required);
            }

        }

        System.out.println((long)denominator-(long)dummy);

This fails on test 4. Can someone tell me why ?

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

My code to F Lanterns fail at some 1200+ test of test case 5. Can someone take a look at my submission and guide me to where my code's failing? Or provide a test case where it fails?

Help will be much appreciated. Thanks!

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

For problem F, there also exists another dp.

For any $$$i$$$, we will assume that we use only the first $$$i$$$ lanters, and define $$$dp(i, j)$$$ to be the maximum possible value of $$$(i + p[i])$$$ among all right-facing lanterns in the first $$$i$$$ lanterns, if the $$$j$$$'th ($$$j \lt i$$$) lantern is the leftmost uncovered lantern.

Transitions are somewhat similar to the editorial, but we require only one segment tree instead of two.

Implementation: link