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

Автор cry, 2 года назад, По-английски

Thanks for participating! Despite the round being unrated, we hope you've enjoyed the problemset. We put a lot of effort into this round :prayge:

I want to give huge thanks to Dominater069 and satyam343 for their heavy contributions to the subtasks of G. If you're participating out of competition, we hope you enjoyed attempting these bonus subtasks. Otherwise, we hope you will enjoy upsolving them!

2009A - Минимизировать!

Problem Credits: cry
Analysis: cry

Solution
Code (Python) (ntarsis30)

2009B - osu!mania

Problem Credits: cry
Analysis: cry

Solution
Code (Python) (chromate00)

2009C - Легенда о лягушке Лее

Problem Credits: Proof_by_QED
Analysis: cry

Solution
Code (Python) (ntarsis30)

2009D - Сатьям и подсчет

Problem Credits: Proof_by_QED
Analysis: cry

Solution
Code (Python) (ntarsis30)

2009E - СУПЕР ДУПЕР БОЛЬШОЙ Массив Кли!!!

Problem Credits: cry
Analysis: cry

Solution
Code (Python) (ntarsis30)

Bonus: Solve in $$$\mathcal{O}(1)$$$.

Code (Python) (Non-origination)

2009F - Запросы Светлячка

Problem Credits: cry
Analysis: cry

Solution
Code (C++) (awesomeguy856)

2009G1 - Запросы подмассивов Юнли (простая версия)

Problem Credits: cry, Proof_by_QED
Analysis: Proof_by_QED

Solution
Code (C++) (yash_9a3b)

2009G2 - Запросы подмассивов Юнли (сложная версия)

Analysis: Solution 1: Proof_by_QED, Solution 2: awesomeguy856

Prologue
Solution 1 (Lazy Segment Tree, Offline)
Code (C++) (vgoofficial)
Solution 2 (Binary Lifting, Online)
Code (C++) (awesomeguy856)

2009G3 - Запросы подмассивов Юнли (экстремальная версия)

Analysis: Dominater069

Solution
Code (C++) (awesomeguy856)
Разбор задач Codeforces Round 971 (Div. 4)
  • Проголосовать: нравится
  • +156
  • Проголосовать: не нравится

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

Auto comment: topic has been updated by cry (previous revision, new revision, compare).

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

The G2 problem can also be solved by the MO algorithm. My solution is:https://codeforces.me/contest/2009/submission/279633321

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

    Can you explain your solution in detail

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

      I've just solved it with mo+sqrt decomposition too. here my 279746467

      The idea is the following:

      1. get array ans from G1 problem. ans[i] means the min number of operations needed in range [i,i+k).

      2. Now, for a query (l,r), the problem reduces to find min({ans[l]}) + min({ans[l],ans[l+1]}) + min({ans[l],...ans[r-k+1]}). This is range queries and it can be solved with mo+sqrt by dividing ans in buckets and sorting the queries

      3. Your bucket size X = q/sqrt(n) // this is an optimal value, no need to explain here. You can also choose X = sqrt(n) as your bucket size.

      4. Sort queries. Say query1 = l1,r1 and query2 = l2,r2. if l1/X == l2/X, then they are on the same bucket and order by r1 < r2. If on different bucket, return l1/X<l2/X. Save original order of queries before sort it.

      5. Answer queries by getting answer from left sid (it just iterates over a bucket size, X) and for right sid I build on every query of the same bucket a vector to save min values of ans[i] and a suffix sum. Then with the min value from left side make a lowerbound to the vector of min values and find the position from which min value from left side is smaller in fector of min values of right position. Use the suffix sum to add the rest to your answer.

      Sorry for large explanation ^-^

      Check mo+sqrt here

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

    It can also be solved using merge-sort tree

    Solution using merge-sort tree: https://codeforces.me/contest/2009/submission/279748718

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

      Can you explain the idea, the code is too messy to read

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

        from G1 we precompute the answer for every window of k and store it in a new array (c). now answer for query (l,r) will be sum(j=l, r-k+1) min(i=l,j)ci. now we construc a merge-sort tree that stores values in (l,r). lets say sub-array c is like cl,cl+1,cl+2,cl+3,...,cr. this vector seg[400001] in (i,l,r) stores cl,min(cl,cl+1),min(cl,cl+1,cl+2),...min(cl,cl+1,...cr). now lets say query is (l,r), and we are in a segment (gl,gr), we also maintain an int pre_mn that calculates min in (l,gl-1). answer from this seg would be min(pre_mn,cgl),min(pre_mn,cgl,cgl+1),...min(pre_mn,cgl,...,cgr). now lets calculate sum of this values using binary search and prefix sum by finding the index until where cgl+i is greater than pre_mn, as it will become pre_mn.

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

binary search forces

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

Nice Div. 3 contest !

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

In problem E i used prefix sum and got MLE bruh...

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

Can we solve D faster than O(n^2) if xi's were real numbers instead of integers ?

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

In the C problem, there is a neat way to check whether there will be any other case or not.

Following the given explanation, one can see, that if any of the points on the side which contributes 2 points to the triangle are moved, the angle increases, and since we can't get them any closer without falling into Case 1, we can't have any more cases.

Another way that can be used is the fact that the slopes of the two perpendicular lines must give a product of -1.

So, if the points were $$$(x_{1}, 0), (x_{2}, 1), (x_{3}, 0)$$$, then we would have :

$$$(\frac{x_{2} - x_{1}}{1 - 0}) * (\frac{x_{3} - x_{2}}{0 - 1}) = -1$$$

which leads to :

$$$(x_{2} - x_{1})(x_{3} - x_{2}) = 1$$$

And since the differences will always be integers, we have :

$$$x_{1} + 1 = x_{2} = x_{3} - 1$$$

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

    It's a good explanation for showing there is no other cases. I came up with similar idea using geometric properties of the median in a right triangle. Other than triangles with sides in a vertical line $$$(x, 0), (x, 1)$$$, triangles must have sides on a horizontal line. Then the median of the right triangle separate out the two parts $$$(x - t, k) ,(x + t, k)$$$ with the last vertex is $$$(x, k'), k,k'\in \{0,1\}$$$. Then the median of length m calculated as $$$m^2 = 1^2 + t^2\ $$$, thus $$$(m - t)(m + t) = 1$$$, with similar argument $$$m$$$ must be 1. Sides on horizontal line is 2, then $$$t = 1$$$

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

~~~~~~

if(x > y){
    cout << 2* ceil(1.0 * x/k) - (ceil(1.0 * x/k) >= ceil( 1.0 * y/k)) << endl;
    continue;
}

else {
    cout << 2 *ceil(1.0*  y/k)<< endl;
    continue;
}

~~~~~

why this fails??

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

G2 and G3 are not div4 problems. They should only appear in div2 or div1.

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

    On the contrary, they cannot appear in div2 or div1

    They are far too standard for both of them.

    They were never meant to be solved by actual participants, A — G1 is the actual div4 round. They are meant to educate higher rated people.

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

      so why have div 4 :/

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

        wdym? why have these "bonus" tasks in div4? or why have div4 at all?

        why have these "bonus" tasks in div4?

        how does it hurt you? Ignore it if you want to. It is not fit for a div2 or div1 clearly, why not have it here incase someone finds it useful?

        why have div4 at all?

        Because we have an abundance of easy tasks and an abundance of low rated people? D

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

      clearly not div4, admit your mistake instead of making baseless points.

      Dominater069 orz thanks for admitting it

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

        They were never meant to be solved by actual participants

        i admitted it lol.

        Not every task exists has to exist for intended participants.

        Authors (and me) wanted to add bonus educational tasks for high rated participants. I really dont understand how the intended audience was affected

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

          I appreciate the extra tasks. G2 is fairly new to me, and G3 was totally new to me. These were good tasks for learning.

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

          honestly, based from previous div 4s, i think G3 (or maybe also G2 idk) should be a bonus question that appears in the editorial, as a challenge

          although it's probably gonna be dismissed by lots of people, it'll be consistent with other rounds where in the editorial, they mentioned that they thought of harder constraints of the problem but not actually inserting it inside the problemset to make the round somewhat consistent.

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

      Why Div.4 have to educate Master or Grandmaster? I cannot understand.

      I think that that an overwhelmingly difficult problem is standard so can't put it in Div.2 doesn't mean that it can plugged in Div.4. I want a good problem must to be placed where a more people can solve it.

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

        Why Div.4 have to educate Master or Grandmaster?

        It doesnt have to, but isnt it good if it does? Who did it harm smh? Experts who want to be able to AK every div4 round. welp sad for them

        Authors tried to do a nice thing by including extra tasks (something which they didnt have to do and still would be paid the same)

        I want a good problem must to be placed where a more people can solve it.

        except G3 or G2 aren't good problems. Educational? sure. But educational problems should not affect rating.

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

          I hate you so much

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

          I think it's more like "it could've benefited more people in a higher division" rather than "it harmed those people."

          While I see your argument, and it may be true that it won't be very good to be in a Div. 1 round, I honestly don't think there would be many solves even if it was in a Div. 2. I agree that standard problems shouldn't heavily affect ratings, but I think the benefits are far bigger to have this problem in a Div. 2 round instead of a Div. 4 round.

          See how many of the 'target' people for these problems have actually participated in this round. If you want to attract those 'target' people and educate them, it needs to be rated for them to be motivated. Candidate masters won't expect a Div. 4 round to actually educate them, so there is little reason for them to even register for the contest and read the problem. It's not like having a few official solves ruins the whole authority of the rating system. It's way more important to motivate the fitting people to read and try the problem.

          Also, G2 was actually an interesting problem for me. It may involve only a few standard techniques, but I don't think such standardness necessarily made the problem bad.

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

            i agree with you that it would be on the edge of being fine for div2 because its hard enough so affecting only small number of people

            But

            • you cant easily port a problem in between rounds, or decide the division based on one problem

            • even if it doesnt affect much, i dont see many div2 coordinators who would accept G3 as a d2F (even though it would be somewhat fine imo)

            • there was a high likelihood that G3 existed on the internet since it is a very natural problem, and indeed it's max variant existed on hackerrank. https://www.hackerrank.com/challenges/little-alexey-and-sum-of-maximums/problem (somebody solved it using this too)

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

          Oh, you think G2 and G3 aren't good problems... Then why they are in contest? Isn't it wierd? Is it OK that not good problems in Div.4?

          But educational problems should not affect rating.

          Then why Educational CodeForces (Div.2) exists? Just do plug all Educational CodeForces problem in Div.3 or Div.4. But there is reason that Educational CodeForces exists.

          And why you're saying like that? Nobody said "I want to solve all of them!"

          I'm just saying that problem must be its suitable position, so it can teach more people. If you do not think so, then I'm sorry. But I believe every problemsetter and coordinator, tester knows that Div.4 is not for Master or Grandmaster, but for Newbie or Pupil.

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

            you think G2 and G3 aren't good problems

            From problem solving perspective, it is mostly standard and implementation for me.

            From eudcational perspective, it is useful as a problem to teach you the power of sweepline algorithms. There can be educational value in a problem despite it not being a "good" problem.

            Then why Educational CodeForces (Div.2) exists?

            It's fake educational and has been for a long time.

            years before, it used to be unrated and containing actually standard tasks. Now, it's just slightly more standard than average div2, but the name stuck.

            This change happened almost solely because they became rated rounds.

            I'm just saying that problem must be its suitable position, so it can teach more people

            But it comes at the cost of affecting people's ratings. Who likes to lose rating to a standard problem? I certainly don't

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

      Without a doubt, this problem cannot appear on Div1, but it is actually fine as Div2F (we definitely had worse and more standard d2F).

      The following only applies to unofficial contestants:

      the mild complaint I had is that I participated in a div 4 round, expecting div 4 difficulties and “div 4 level resistances” only to find that this is not the case. Div 4 to me had been a “quick and easy AK and funny internet speed test with no verdicts for 10 minutes and so every penalty is worth 25 or more”. In fact, div2/3/4 (and obviously also div1) have distinct feels to it, so I am not so sure in general making it feels like div2, which is what happened when G2 and G3 we’re included.

      This only made sense under my belief that this problem can totally be used on D2F as is.

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

        G3 is probably not fine as 2F either, as there is a square root solution which is trivial to think of (no sweepline or monotonic stacks or rectangle queries) but annoying to implement (279798653).

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

          Can you explain it in more details? I fail to see anything sqrt that isn’t a reinterpretation of a rectangle queries, it doesn’t seem like your solution is MO’s based.

          it is also worth noting that G3 is also trivial if you have segment tree beats (range chmin, historic sum). Implementation is at least half of the problem.

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

            I have solved it by processing queries offline.

            I iterate over the leftbound $$$l$$$ of the query in decreasing order, while maintaining two arrays $$$p$$$ and $$$q$$$ through my square root structure.

            When at a certain $$$l$$$, $$$p$$$ and $$$q$$$ are defined in the following manner:

            • $$$p_i = f[a_l, \dots , a_i]$$$
            • $$$q_i = \sum_{j = l}^{j = i - k + 1} {f[a_j, \dots , a_i]}$$$

            So the answer for any query $$$[l, r]$$$ simply becomes $$$\sum_{i = l + k - 1} ^ {i = r} {q_i}$$$.

            To maintain this array, my square root structure needs to be able to perform the following kinds of queries:

            1. $$$p_i \leftarrow x, \; l \leq i \leq r$$$ for some $$$[x, l, r]$$$
            2. $$$q_i \leftarrow q_i + p_i, \; l \leq i \leq r$$$ for some $$$[l, r]$$$
            3. Compute $$$\sum_{i = l}^{i = r} {q_i}$$$ for some $$$[l, r]$$$.

            which can be done.

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

              Your solution is identical to the intended one (Edit; after a slight more read on the intended solution it may have some subtle differences, nonetheless, it is identical to mine). It is just that you happens to choose to implement it via sqrt structures.This task could be completed by (lazy) segment tree too (no beats). I would say this is just difference in preference and the fact that it is passable by sqrt does not make it easier.

              Perhaps, this task is more standard/widely known to be doable by sqrt. In this case, then the task would be more standard than what I initially thought.

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

      me, who on;ly solved A-G1 :(

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

      I agree but I think it would be a better fit for a Div.3. Div.3 contests still contains standard questions

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

      Ye G2 and G3 educate me, I don't know why the problem like this can't appear in div2 or div1, only observe problem can. It would be nice if Codeforces Div 2 mix observe problem and standard problem :)

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

    I can see G2 barely being on the edge of a Div. 3 but G3 is straightforward way too difficult. It's maybe a harder one even for a 2F.

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

      G3 is definitely below d2F level

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

        I think it's more like most of the other 2Fs are too difficult in general, but okay.

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

          if most 2F are more difficult then that’s the 2F difficulty level lmao

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

            You can say the same thing to this: if we keep having these kind of problems in 4G, then this becomes a 4G level problem. However, that would be far from what I'd expect from a 4G, and 2F is kind of such state already.

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

              I agree that G2/3 are beyond div 4 level but I think it’s clear that they’re not intended to be solved by div 4 participants

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

                But they are in a DIV4 contest

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

                  It's an extra problem to be upsolved for education value. What harm did putting these questions here do? Did it affect anyone? No. Only 1 trusted user solved G2 and G3.

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

                  Maybe my opinion is stupid but when you say a DIV4 contest, I expect a contest that contains problems that a DIV4 participant can solve or upsolve. Similar logic for other divisions. But it is fine. Feel free to put a Div1F in the next DIV4 contest.

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

                  How many people in division 2 can solve F you think? What about the old div 4 G about 2-sat? Do you think newbies and pupils have a chance of inventing that on the fly without seeing 2sat before? Almost every final question on each round is far too hard for its division. We only included G2 and G3 because they follow quite naturally from G1, and if is impossible to port questions between rounds.

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

                  I never said the past div4 rounds were perfect. Also, I said I expect the target participants to be able to SOLVE or UPSOLVE the problems. So, because every final question on each round is too hard for its division, every round should follow this pattern? Anyway, it is your round, do as you want.

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

                  "Also, I said I expect the target participants to be able to SOLVE or UPSOLVE the problems."

                  Ok? isn't that the purpose of G2 and G3? For div.4 participants to upsolve? Of course, you don't have to upsolve it right now. You can always come back when you're better. The problem doesn't disappear.

                  I don't see any harm in contests with a harder final problem than its intended division. It gives strong participants of the intended division something to think about for the rest of the contest (instead of doing nothing), and makes more of a competition for higher rated participants.

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

                  do you really think that average div 4 users are gonna be able to understand the editorial for G2 and G3 just so that they can upsolve it hours or days after the contest? the point of upsolving a round that is consistent with your division is so that you can get AC on all of the problems by understanding what the editorial said shortly after the round ended. this is why most difficult problem in div 4s is usually around 1700-1900ish (that 2-sat 2100 problem doesn't count), because although most div 4 users cannot come up with the idea during the contest, the authors knew that some (not very small group of) div 4 users will understand the editorial given for the problem so that they can upsolve it immediately (or after some short period of time)

                  also, "makes more of a competition for higher rated participants" ok but the intended target for this round are pupils lmao

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

                  If you can’t understand G2 or G3, you can pretend those problems never existed, and move on. Alternatively, you can note their existence down and return later. It’s up to you.

                  A-G1 already makes a complete div 4.

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

                  so basically G2 or G3 is equivalent as the Ex problem in abc, where sometimes it's so hard it's not even intended for users who partake in abc

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

      I don't know if G3 is really div2. F level. I just brute-forced my G2 solution with a random optimization and it got AC (after the contest). Here's my Submission.

      If anyone is interested, try to hack me!

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

        Hacked, brute forcing with a G2 solution would result in $$$O(n)$$$ per query in worst case. Hence, if there are many instances where $$$ind = i + 1$$$, you are not skipping much numbers and therefore TLE.

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

          I also knew that it would give TLE on a case where my array ans[] had consecutively increasing elements. But I was not able to think of such a case.

          Not sure how it managed to pass all the pretests.

          Btw, thanks for hacking.

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

Sharing my video of winning the round along with explanations of my solutions: https://www.youtube.com/watch?v=JhL-oPzptlI

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

I tried solving E by interpreting it as a function and using the quadratic equation, but it keeps giving the wrong answer for n = 1000000000, k = 1000000000

typedef int64_t ll;
ll n, k, sk;
cin >> n >> k;

sk = gauss(k - 1); // starting k : the gauss sum of the numbers before the start of the series

ll max = gauss(k + n - 1) - sk;

// quadratic equation

// pref = gauss(n) - sk
// pref = (n^2 + n)/2 - sk
// where does 2pref intersect max? (because we want pref = max-pref)
// n^2 + n - 2*sk = max
// n^2 + n - (2*sk + max) = 0

// a = 1, b = 1, c = -(2*sk+max)

// delta = 1 ^ 2 - 4 * -(sk+max)
// delta = 1 + 4 * (2*sk + max)

ll delta = 1 + 4 * (2*sk + max);

// x1,2 = (-b +- sqrt(delta))/2*a
//	= (-1 +- sqrt(1 + 4 * (2 * sk+max)))/2 

ll x1 = round((-1 + sqrt(delta)) / 2);
ll x2 = round((-1 - sqrt(delta)) / 2);

ll x = min(abs(x1), abs(x2));

ll ans = 2 * (gauss(x) - sk) - max;
cout << abs(ans) << '\n';
  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    was stuck in that for some time, but then used unsigned long long and it worked.. But came to the comments to see that it can be done by using binary search, need to see how they are applying it to the V curve, i mean ternary can work but binary.. no intuition honestly

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

For G1: There's a mathematical logic behind "ai — i". Let's say we have a sequence "(C, C + 1, C + 2, C + 3 + ...)". Any 'ith' element ai will be equal to "C + i — L", where 'L' is the starting index of the window. So (ai = C + i — L) => (C — L = ai — i). This (C — L) is a static part, which means we have to find the maximum occuring "ai — i".

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

I think G1 can be solved by finding the longest increasing subarray for each query in O(logN)

Ans will be (right — left + 1) — longest;

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

My solution 279640569 of F, is giving correct output as 13 on my local and online compilers but wrong answer as 12 on codeforce's judge for following test case:

1

5 1

4 8 3 2 4

7 10

Can someone explain it?

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
import java.util.*;
 
public class one {
    public static void main(String[] args) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
 
        int t = sc.nextInt();
 
        for (int i = 0; i < t; i++) {
            long x = sc.nextLong();
            long y = sc.nextLong();
            long k = sc.nextLong();
            
            long jumpsX = (x + k - 1) / k; 
            long jumpsY = (y + k - 1) / k; 
 
            long moves = Math.max(jumpsX, jumpsY) * 2 ;
 
           
            if (x>y) {
                moves--;
            }
 
            System.out.println(moves);
        }
        sc.close();
    }
}

why wasnt this AC for the frog and freya question?

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

can somebody explain how they used binary search for E? i found the function to be unimodal and hence i applied ternary search to find the point of minima, i dont get the intuition for binary search (i dont see monotonicity)

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

The entire universe is against me for becoming pupil. Was doin super well today until that announcement appeared, L cry, L servers... MikeMirzayanov I think its time to add a new god damm server.

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

I miss SlavicG,mesanu,flamestorm ... (╥﹏╥)

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

Here is a clean(er than the edi) solution to C and a unique solution to D.

For C we can see that

Spoiler

As for D, which I found much more interesting, though do note I misread it and as such overcomplicated it.

Spoiler

Here are submissions for both, hope that puts these problems into a bit of a different perspective! C: 279561294 D: 279622363

This contest had quite a few issues with the queue and pages loading, however I still enjoyed the problems and I hope you did too! I would have gotten plus VE if this contest was rated however instead of complaining I had fun solving these problems even if I did overcomplicate D a bit, however it would give insight to a possible harder version of the problem if it was not only 0 and 1 on the Y.

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

This was a good round, sad that it got unrated.

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

thanks for writing, issues not your fault!

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

I have a different solution for G2. Use a set and a map to get the minimum moves for the window of size k starting from every index. Then use a stack to build a vector to store the index of next smaller number. Then use jumps to next smaller number to compute answer for every range.

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

Nice Div3 Contest !!!

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

I loved the HSR and Genshin references. Please do continue naming problems on our favourite characters. Thank you!

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

We can use binary search to search for the greatest i such that a1+⋯+ai≥ai+1+⋯+an

Isn't the solution for E wrong? If the above statement is the correct solution, the greatest i is just len-1 no?

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

In problem E's editorial ...

We can use binary search to search for the greatest i such that a1 + ⋯ + ai ≥ ai+1 + ⋯ + an . Note that here, the positive difference is minimized. If we move to i+1 , then the negative difference is minimized (since the sum of prefix will now be less than the sum of suffix). The answer is the minimum absolute value of both cases.

It should be a1 + ⋯ + ai ≤ ai+1 + ⋯ + an because we want to minimize the difference.

cry
(ignore the formatting)

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

Can't understood editorial solution for G2

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

G2 can also be solved using sqrt decomposition in $$$O(Q*N/B*log(B))$$$ where $$$B=\sqrt{N}$$$.

For each query, maintain the answer from left to right. If the current minimum is greater than the current block's minimum, we can use a binary search to find where the current block's first minimum is.

Submission: 279662760

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

Can we use ternary search at the problem E, though we need to find the minimum here?

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

anyone mind to explain solutions of G3?

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

Can someone suggest a testcase where this will fail for C? It fails on testcase 2.

wrong answer 862nd numbers differ — expected: '2', found: '1'

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

The solution to A talks about choosing c and then talks about "distance".

The solution to Problem D doesn't even mention (let alone prove/sketch) that the mentioned right-angled triangles are the only ones.

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

    Thats because people who read the editorial for A and people who read editorial to D are different audiences. Obviously more experienced people need less intermediate steps to understand a solution. Look at any div 1 F solution and see how fast paced they are.

    I remember the general guidelines is to keep solution to every problem approximately equal lemgth.

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

last 3 problems G123 were actually suitable Div2DEF I think since many red & orange people couldn't solve G23.

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

Nice div3 so im sad for urt

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

My submission to problem E was exactly the bonus solution mentioned in the editorial. I spent around 1 hour debugging during the contest but the last sample case was failing. After the contest I submitted the same solution and it passed. I believe there is some precision bug in Apple clang. Can anyone else try this on the last sample test?

** Please ignore the excessive use of long double. I was getting panicked :) **

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

Hi guys I'm new here. When a solution is provided in C++ does that imply that the time constraint for the problem is not achievable using a language like python?

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

Great problems G1,G2,G3! It's nice to have bonus educational problems like these, although I feel like these problems could've also been placed in a div 3 round, since more higher rated participants take part in div 3 rounds than div 4.

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

1 2 2 1 3 2 1 2

Is this a valid test for G1?

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

Dominater069 Test cases of Problem G3 are too weak.

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

In problem G2 binary lifting solution, what does w(h, i) mean?

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

why my solution in G1 wrong :<. my solution did i forgot to reset something?

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

G3 binary lifting almost the same as G2.

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

Can anyone kindly tell why this approach is wrong towards E- KLee's super duper large array submission

I am starting from k and ending at n+k-1 as my high. Then for each mid value, i am finding the prefix sum till that and suffix sum and finding absolute difference. Whichever gives us minimum is the answer.

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

can someone explain the lazy segtree solution for G2 in more detail please?

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

Gif in D singlehandedly lowered the rating by 200pts

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

G2 can also be solved offline without lazy segment tree using prefix sum and binary search
281048790

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

Can Persistent Segment tree be memory limit exceeded in G3 ?????. I'm going to implement 4 persistent segment tree but maybe it is not good idea