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

Автор diskoteka, 3 года назад, По-русски

1848A - Вика и подружки

Идея: diskoteka

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

1848B - Вика и мостик

Идея: diskoteka

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

1848C - Вика и ценники

Идея: pavlekn

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

1848D - Вика и бонусы

Идея: diskoteka

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

1848E - Вика и блинчики

Идея: diskoteka

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

1848F - Вика и вики

Идея: pavlekn

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

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

Bro had a breakup revenge

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

A,C,D and E are just math problems. Cf should do better.

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

Problem statements were too long.

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

guess getting stuck in problem A was a sign I should not appear for this round

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

look at As editorial :0

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

I agree with the general mood that A-C of the contest were too hard. D-F were okay, although in E $$$M$$$ should have been set larger than $$$O(Q \log x)$$$ to prevent the edge case where one of the prime powers reaches $$$M$$$.

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

    Why should setters prevent corner cases instead of contestants preventing them in their code?

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

      This is a Div 2 codeforces contest. Because this is Div 2 where the contestants aren't necessarily that strong, and because this is codeforces where the pace of the competition is very fast, it should be more about solving the problem than implementation and avoiding corner cases.

      Also, it looks like the authors made the same mistake, hence the explanation that Test Case 15 (the first case with that corner case) was incorrect and the solutions had to be rejudged.

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

        This is a Div 1.5 contest, so include purples in your thesis. "not strong div2 participants" wouldn't reach E anyway.

        Btw my opinion on this problem is: why the fuck is it variable mod? Why not just use constant mod 1e9 + 7? It seems some coordinators or setters are addicted to using variable mod for no reason other than worsening the runtime of people's solutions.

        I didn't know about test case 15, that slipping by testing is a big oof.

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

          There are problems where variable mod is needed, in particular the problems where there are limited amount of parameters and it's possible to locally compute all the possible answers with a slower code then submit the result.

          I agree that for this problem there is no such reason and a constant 1e9+7 is better.

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

          Div2 contestant also should have rights to solve E with certain wisdom ,instead of getting cornered by this kind of modulo trick. In fact that’s almost irrelevant to the main idea of this problem, which i think is conducting the numbers of factors (forgive my terrible English)

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

      well, stupid edge cases are no fun (the original problem when i tested had a constant mod > 1e9)

      also, the setters themsevles got the case wrong....

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

I liked A and B, even though the latter was mostly implementation. C and D were too mathy and guessable though.

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

problem statement of A was pretty confusing for me.

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

There exists an $$$O(n)$$$ solution for problem C, which is better than the editorial's $$$O(n\log a_i)$$$:

Submission

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

    Can you explain your solution, i read but i can't understand

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

    This is O(n log(n)) Only to calculate the number of trailing zeroes it takes log(n) times only.

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

      Hi, __builtin_ctz() is an inbuilt function of G++ that only have $$$O(1)$$$ complexity as far as I know. Correct me if not:)

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

        https://codeforces.me/blog/entry/59268

        Though it does the bitwise calculation, it is too fast to get noticed, but the complexity is still O(log(n)). You can verify this by manually writing the code for it, and you will see that it takes the same time.

        Click on compare the previous solution in the below submission.

        https://codeforces.me/contest/1848/submission/214137912

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

          I can't really agree. It seems on my local machine that __builtin_ctz(x) is at least 30 times faster than the handwritten one. as the handwritten one has the complexity of $$$O(\log n)$$$, I would say that __builtin_ctz(x) has to be something like $$$O(1)$$$.

          Here's my code and results:

          Test 1:

          __builtin_ctz() running 1e7 times, 0.02 s on average
          handwritten __builtin_ctz in your previous submission running 1e7 times, 0.6s on average

          Test2:

          change the lim in the first code to $$$10^8$$$, and it runs 0.2 s on average; change the lim in the second one to $$$10^8$$$, and it runs 6.1 s on average.

          What do u think about that?

          upd: i did another test, i changed the get(x) to:

          int get(int x)
          {
              return 2*x;
          }
          

          and $$$lim$$$ is still $$$10^8$$$. the average time is 0.24s! That means the inbuilt function of g++ seems to be even faster than adding two numbers together! What's ur opinion?

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

    how did you arrive at the intuition of using 2 highest power in solving it.

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

This contest problem statements are too long like a reading comprehension.

I think C is more difficult than D

May be I'm too foolish , but what is the tutorial of C's meaning???

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

Personally I don't think problem A is too hard for its position. The idea is fairly common in game theory puzzles like https://www.youtube.com/watch?v=dh4nEuhZBgg and just requires a bit of good intuition.

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

diskoteka [user:pavlovn]

My thoughts on this round:

The problems themselves were fine.

I do think A was not suitable to be a div2A, but that’s because I think div2A’s should be “submitbait”. The problem itself was fine, and may have done better as div2B.

Perhaps D was too math-y than ideal, but that’s fine.

Perhaps E could’ve had $$$M \geq 10^8$$$ or have been fixed, but it wasn’t much extra (and it is not too hard to generalize to all $$$M$$$). It is bad that the sequence is on OEIS though, so ideally this problem shouldn’t have been used.

Also, don’t listen to the haters, and please keep setting contests. Over time you’ll get better, and this contest probably provided good feedback!

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

C was a beautiful problem!

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

Your tutorial for problem D should write (b+20x)(a-4x), not (b+20x)(a-x) in the 4th paragraph, as reflected in your code.

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

Easier for F is just doing binary lifting as soon as you know the power of 2 thing. It's basically the same solution but O(NlogN) and you don't have to think about reducing it to an array of size N/2.

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

For problem A, vika's friends can see her(vika) right? So they see her and try to modify their movement right? Can vika see her friends as well?

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

    If we color the rooms like a chessboard, and at least one of her friends starts on the same color as her, that friend has the strategy, and can react to her movement(because she moves first) in such a way that no matter what she does, she eventually will be caught, this is explained in the editorial. So, whether Vika tries to avoid her friends or not, it doesn't matter.

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

please explain me this(Problem A):

1 2 1

1 1

1 2

I think when vita goes to right , friend will catch him . Perhaps, i misunderstood something.

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

This is the WORSR contest i've ever seen. Can you just stop writing such long description of problems?? If you want to show your ability of writing, you don't need codeforces. And problems DEF are so easy to think, the difficulty is too low to be the div2 DEF, it can be used in div3. The quality of the problems are also too low I think. And the awful test cases of problem E, can you just check your test cases before the contest? To my surprise, this contest has not been unrated, but I don't want to see such contest like this anymore. YOU DO NOT NEED TO CREATE THE CONTEST IF YOU DO NOT HAVE THE ABILITY OR YOU DO NOT WANT TO DO IT WELL!!!

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

when problem A has the longest tutorial, you know you did something wrong.

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

wthforces

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

I don't get why so much hate for this round. A is better than normal, I liked problem C quite a bit, and rest of problems were fine. (yet another round with no datastructure tho ;-;)

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

Sorry ,but I feel A lengthy and language is very tricky

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

pavlekn, откуда взялось вот это равенство в разборе F? a[2^t][i]=a[2^(t−1)][i]⊕a[2^(t−1)][next(i,2^(t−1))]

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

In solution1 of problem C , it will be ai-4*bi in place of ai-4ai

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

can someone explain me the problem statement of B in easy way.. i have read it multiple times but i am not able to understand

thanks..

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

Problem A was way too unbalanced for its position and difficulty range. Its not a great idea for begineers

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

in task B, isnt it necessary to mention in the problem statement that k distinct colourst will definitely be present.

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

My solution for A :
So we need to check for every position (i,j) in n*m grid, if there is a position where both main person and anyone among the k people have the same distance to (i,j). So we iterate over every position and check whether the distance of main person is same as distance of any of k friends to that position. TC : O(n*m*k).
AC code : 214108505

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

After reading editorial for problem A, do you still feel like this is DIV-2 A problem ?

diskoteka

Only in Vika-land, problem would need this much logical thinking and proof for problem A solution.

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

Because of problems like A, people start to hate math in cf-contests. The problem would be great if it were at the math contest, but not at cf.

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

If someone is making a video tutorial on A and B please share it

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

Personally, I loved this round! I only solved ABCD, but this round had better problems than most recent Div2s in my opinion. I don't understand why the announcement blog post was downvoted. Keep making rounds!

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

ive done other coding contests but this was my first cf contest and i solved 0 questions, so skill issue for me ig

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

In problem C, I have a different way of finding the $$$cnt_i\% 3$$$ mentioned in the editorial.

Similar to solution 2, we will build the sequence from the end. It will be of the following form:

$$$... x, x/2, x/2, 0 ...$$$

Now try to build a tree of all possible values before $$$x$$$. You will notice values in a particular level are either of the type $$$odd * x / 2$$$ or $$$k * x$$$ where $$$k$$$ is a positive integer. You will also notice that $$$k * x$$$ has a period of $$$3$$$, same as the period of $$$0$$$.

So the problem reduces to finding which of the $$$a_i, b_i, c_i$$$ is of the type $$$k * x$$$.

Here's my submission.

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

    i am still not able to understand your approach, can you explain in more simple way. thanks.

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

      Think of the first time $$$a_i$$$ becomes zero. It will be of the following form:

      $$$...k, k, 0...$$$

      What would come before $$$k$$$? Let it be $$$y$$$, solving $$$|y - k| = k$$$ we would get $$$y = 2*k$$$. So the sequence now becomes

      $$$... 2*k, k, k, 0 ...$$$

      Similarly, try to find what would come before $$$2*k$$$. From here, multiple values might be possible for each position. For example, before $$$2*k$$$, both $$$3*k$$$ and $$$k$$$ are possible values.

      Try to draw a tree of these values. $$$2*k$$$ will be the root and $$$3*k$$$ and $$$k$$$ are its children. It will be something like this: https://binary-tree-builder.netlify.app/?indextree=2*k,3*k,k,5*k,k,3*k,null,8*k,2*k,4*k,null,4*k,2*k.

      In this tree, at each level, the values are either of the type $$$even*k$$$ or $$$odd*k$$$. You will also notice $$$even*k$$$ has a period of $$$3$$$, just like the period of $$$0$$$.

      Now consider a situation where $$$a_1 = even*k$$$ and $$$a_2 = odd*k$$$. Then we know that both $$$a_1$$$ and $$$a_2$$$ won't become $$$0$$$ at the same time.

      So we need all $$$a_i$$$ to be $$$even*k$$$ or all $$$b_i$$$ to be $$$even*k$$$ or all $$$c_i$$$ to be $$$even*k$$$. Only then we will get all zeroes at the same time.

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

diskoteka, in the editorial of C, while writing Solution 1: I believe where you wrote

(ai, bi, ai — bi, ai — 2 * bi, ai — 3 * bi, ai - 4 * ai)

(and should have written: ai - 4 * bi)

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

Have anyone solved Problem-A using BFS without getting TLE ? looking at the constraints, I thought it was a graph related problem but getting TLE on pretest 3.

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

Thank you diskoteka for great math problems, better than previous div(1,2) speedforces

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

E and F are well known math problems.

E: 2016 AMC 12B P16

F: Trivial special case of 2023 USA TSTST P9

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

It has been pointed out to me that the setup for F is actually identical to USA TSTST 2023/9 with $$$p^e=2$$$, although I’m not sure how much knowing the solution to the TSTST problem helps with the codeforces and vice versa. At the very least, one of the solutions to the TSTST problem proves that you will never print $$$-1$$$ (see the first claim in post #5 by a familiar-looking user).

Edit: sniped by the person who pointed this out lol

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

Great round! Like these problems very much :3

We've found some alt ways to solve F, but they have higher time complexity.

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

A is too hard...

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

I think problem A is harder than problem B.

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

Different Approach For Problem C. Code

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

Then, if the cycle is "scroll" x times, the discount will be (b+20x)(a-x)

WHY NOT (b+20x)(a-4x)?

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

In C, I tried to find the number of operations to make ai zero manually in the hope of getting some pattern or some formula but all in vain. May be they should try not to give such mathematical things till C.

C is one of those problems which gives neither the pleasure when I solve them nor guilt when I could not.

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

Can someone break down C for me, I observed a few things during the contest.

Let a>b for all below expressions, if not we can just move to the next stage where b and |a-b| will fit the scenario(moving one parity ahead).

Every pair will eventually reach a loop of GCD(a,b), GCD(a,b), 0. So essentially we needed to check if every pair have the same parity (%3 values of the number of steps they reach 0). I also noted that we can go from a,b to a%b,b keeping the same parity, except for when (a/b ==1). And that is where it stopped for me.

I saw some people use a%2b to move a parity ahead, but where does that 2 come from?

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

    I'll use pair notion meaning $$$(a, b)$$$ pair becomes $$$(b, |a - b|)$$$.

    Consider some large $$$y$$$ and small $$$x$$$: $$$(x, y) \Rightarrow (y, y - x) \Rightarrow (y - x, x) \Rightarrow (x, y - 2x)$$$.

    We made 3 operations meaning it wont change amount operations modulo 3, therefore you need to find largest $$$k$$$ i.e. amount of operations that: $$$0 \lt = y - k(2x) \lt 2x$$$ which is literally a definition of remainder.

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

      can u prove doing this way + perform the said operation will not be more than logarithmic

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

        I don't understand why do you need to prove this fact since it's literally gcd-like + you literally can implement it and test on big random numbers but here you are:

        Since operation in pairs are not simmetrical you can't assume WLOG $$$x \leq y$$$ so I'll let you do $$$x \gt y$$$ by yourself ;)

        So I'll be doing $$$x \leq y$$$ case:

        Now consider two cases:

        1. $$$4x \geq y$$$, then pair $$$(x, y)$$$ becomes $$$(y, y - x)$$$ where $$$y - x \leq \frac{3y}{4}$$$, $$$(y, y - x) \Rightarrow (y - x, x) \Rightarrow (x, y - 2x)$$$. Congrats! we have reduced second term by at least 3 quarters, since $$$y - x \leq \frac{3y}{4} \Rightarrow |y - 2x| \leq \frac{3y}{4}$$$

        2. $$$4x \leq y$$$, then $$$(x, y)$$$ becomes $$$(x, y \ \% (2x))$$$. Congrats! we reduced second term by at least half

        This yields next conclusion: rough estimate for upper bound of steps is $$$3*log_{4/3}(y)$$$ which is good enough. The rest of the proof is up to you

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

Typo in d editorial:

$$$(b+20x)*(a-4x)$$$

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

I found a very interesting pattern for problem C. For every i, we count number of trailing zeroes in binary representation of A[i] and B[i], now if A[i] has more, then this pair can be made 'dull' in 3k steps, if B[i] has more, then 3k+1 steps, and if they both have equal trailing zeroes, then 3k+2 steps. And we just have to ignore A[i]=B[i]=0 case.

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

Can someone provide me with clear insights on Problem C? Or provide resources to learn the topic. It is clear to me that the only thing that matters is the modulo 3 of the first occurrence of zero for each position of the array. But I find the tutorial very confusing on how to proceed further (maybe I am missing some number theory / modular arithmetic prerequisites)?

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

    Consider several cases of a[i] and b[i]. Such as:

    1. Both are odd. [O,O]

      • Then the first difference ($$$O-O = E$$$) will be an even number. [O,E]
      • second difference ($$$O-E = O$$$) will be an odd number. [E,O]
      • third difference will be an odd number. [O,O]
      • Now, we know that the sum of the numbers keeps reducing and one of them reaches $$$0$$$ eventually.
      • So at what parity can a[i] = 0 occur from above observations?
      • Ans: At all "second differences" , because zero is even
    2. Similarly analyse cases of [O,E] and [E,O]

    3. The case of [E,E] is interesting. You can observe that they will mimic the behave of the numbers we obtain by doing successive division by 2.

      • Eg: [4,6] will mimic the behaviour of [2,3].
      • So case 3 can be collapsed into cases 2 and 1.

    You know the story after this.

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

Did everyone lose rating? Half of the people must have gained acc to algo

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

I didn't understand the solution explained for problem C. Can someone explain it clearly.

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

Who can explain the tasks C, D? I didn't understand the author's decision at all

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

    problem C:

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

The tutorial is clear.

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

WTF you haven't said that sum of Ks over all test cases is at most 200000 in B!

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

Is the kind of reasoning used in problem E familiar to high-rated coders? Looking at the tutorial, I don't see any way I could have solved the problem on my own, so I want to know if people who solved it are well-versed with such kinds of reasoning or if it came to them naturally.

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

Can someone please explain what does area to Vika mean? Is it something other that the number of blocks between Vika and one of her friends?

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

Simpler Solution for A:

  1. Every move, the parity of R+C changes by 1 for both Vika and her friends. Therefore, a friend can catch up to Vika if and only if the sums of their coordinates have the same parity.

  2. Because the friend moves after Vika, she can always decrease the distance between the two of them. By contrast, Vika can only increase distance by moving in the same direction as the gap between her and her friend (e.g. if Vika is three units to the right of her friend, she can only decrease horizontal distance by moving to the right). Because the map is finite, Vika will be forced to decrease the distance between her and her friend after a maximum of R+C moves, and so she will eventually be captured.

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

Problem E Observation: # of odd divisors = # of distinct initial f can also be proved in the following manner:

  • Consider all the pairs of [l,r] such that $$${\sum_{i = l}^r i = x}$$$

  • We are sure the the lengths len of all these segments have to distinct

  • So we need to find what all valid lengths are there. We have the following formula

$$$x = len \cdot ((len+1) / 2) + len \cdot k$$$
  • Consider one of the case where len is even. The case when len is odd is similar to prove.
  • let len = 2p and p>=1
$$$x \equiv len \cdot ((len+1) / 2) \pmod{ len }$$$
$$$x \equiv p \cdot (2 \cdot p + 1) \pmod{ 2 \cdot p }$$$
$$$x \equiv ((2 \cdot p) \cdot p) + p \pmod{ 2 \cdot p }$$$
$$$x \equiv p \pmod{ 2 \cdot p }$$$
$$$x = (2 \cdot t + 1) \cdot p $$$
»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

where did the formula (b+20x)(a-x) in D come from?

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

    In any case, except for 5 and 0, the last digits will start following the pattern of 2,4,6,8 after a certain point. so we can make the formula as for not taking a discount 4 times we will have an increase in b by 20(2+4+6+8) and a decrease in the number of purchases left by 4.

    if we do this process x times then the discount i can get is (b+20*x)*(a-4x).

    and the formula in the editorial is partially wrong(missed 4*x).

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

I have created video editorial for problem A,B and C in english link. If you understand it, upvote.

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

Can anyone please give me a more intuitive idea of the induction of problem F? I mean how can we see it happen beside trying to prove the equation?

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

Maybe there is something wrong with problem A statement. What will happen when $$$n=1,m=1$$$?

In this case none of the girls can move to the neighbouring rooms, which violates your statement.

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

Finding $$$cnt_i\%3$$$ in problem C is not that hard I think.

$$$[a,b]$$$ will change like this $$$[odd,odd] \to [odd,even] \to [even,odd] \to [odd,odd] \to ... $$$

And $$$a$$$ can be $$$0$$$ in only $$$[even,odd]$$$.

(of course if both number is $$$0$$$ a is always $$$0$$$ and otherwise we can divide numbers by $$$gcd(a,b)$$$ so we can remove $$$[even,even]$$$ case)

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

Can anyone share there solution for D using ternary search. Mine is failing. My solution for D

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

In Problem D why are we only subtracting 1 from k after every iteration, shouldn't we take into account the fact that we are performing 4 * x number of operations and adjust k accordingly?

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

cf should do better

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

A can be done through brute force too , just go to each cell , if distance from vika's starting cell == distance from any of her friend's cell , then vika can't escape

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

great contest, do consider making more contests please. [user:diskoteka][user:pavlekn]

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

I spent quite a long time upsolving C in coming up with the formulas to accelerate the procedure when $$$a \gt b$$$... I have no knowledge of gcd algorithms... how can it make the problem easier?

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

Alternative solution to F using SOS DP:

Notice that the value of $$$a_0$$$ after $$$k$$$ operations is the xor of all $$$a_i$$$ such that $$$\binom{k}{i}$$$ is odd.

Why?

Lucas's theorem states that $$$\binom{p}{q}$$$ is odd if and only if $$$q$$$ is a submask of $$$p$$$. Thus, the value of $$$a_0$$$ after $$$k$$$ operations is the xor of all $$$a_i$$$ such that $$$i$$$ is a submask of $$$k$$$. This can be computed in $$$O(n \log n)$$$ using SOS DP. We know that after $$$n$$$ operations all $$$a_i$$$ become zero, so the answer is the first moment that $$$a_0$$$ becomes zero and stays zero.

Submission

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

F: Could the answer be -1? Why?

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

I'm wondering how is one suppossed to come up with a proof such as one presented in tutorial E (or even think of proving the idea that number of odd divisors affects the answer)? Is that even Div2E level? The ideas used in the proof such as considering the parity of $$$cnt$$$ seem so random to me. I'd be grateful if any math gods would explain to me how to think about such problems or if you would show me more intuitive proof than the one in tutorial.

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

In Problem B, can anyone tell, why we are returning ans — 1 as given in the solution

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

nvm

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

wow, I have never seen calculus in a cf problem until now