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

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

久别无恙, Codeforces!

We are glad to invite you to take part in Codeforces Round 942 (Div. 1) and Codeforces Round 942 (Div. 2), which will start on Apr/30/2024 17:35 (Moscow time). You will be given 6 problems and 2 hours and 30 minutes to solve them in both divisions. Some problems will be divided into two subtasks.

The problems were authored and prepared by N_z__, wyrqwq, yinhy09 and me rui_er.

We would like to thank:

Score distribution:

  • Div. 2: 500 — 750 — 1500 — (1000 + 1500) — 2500 — 3500
  • Div. 1: 750 — (500 + 750) — 1250 — 1750 — (1750 + 1000) — 3500

We hope you'll like the problemset!

UPD: Congrats to the winners!

Div. 2:

  1. 3_m
  2. RinaRin
  3. eightniko
  4. liumohan
  5. golomb

Div. 1:

  1. tourist
  2. jiangly
  3. jqdai0815
  4. gamegame
  5. Kevin114514

Editorial is out.

  • Проголосовать: нравится
  • +361
  • Проголосовать: не нравится

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

Hope to get postive delta!

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

Looking forward to this high-quality contest.

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

rui_er!

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

As not a tester,I don't know how this round is like.

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

As a problemsetter, hope you have fun!

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

How hard will this round be? They are known to create hard problems. :/

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

So sad that I can't participate this contest, GLHF

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

Hope for high-quality problems!

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

As a tester,

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

As a tester, I tested

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

I hope this is a perfect competition.

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

As a tester,I also tested :)

GLHF!

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

I am curious about why this contest changed into div1,div2. I remember it was div1+div2 until yesterday.

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

    The sponsor is not available.

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

      What’s the reason to prefer separate rounds over a combined round?

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

        So you can't increase rating by beating div2 people.

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

        Certain div1 people have replied to me with "so i dont need to solve 2 more trivial problems"

        Doesnt make sense to me because it takes 5 mins but ok

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

          As far as I know, separate rounds are just the default for historical reasons. I think there is no big difference between separate and combined rounds (i.e., just those 5 minutes).

          [maybe having separate rounds instead of combined rounds also affects the rating system? I have no data about that]

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

            If this was a combined round, maybe hack and FST would not have occurred in Div1-D.

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

    Clearly,this will make it more difficult to increase the rating.(

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

QP

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

As we all know, cute rui_er is a kind of ruler.

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

OMG ruler round

She always come back

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

orz wyrqwq

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

rui_er!!!

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

As a tester I don't know what to comment.

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

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

     This is what I acknowledged from Algodoo marble races, so the figure above actually disobeys the rule in Algodoo.

    Purple HSL: [270, 100, 100]

    Violet HSL: [300, 100, 50]

    And, more astonishing, violet belongs to Team Pink, not Team Purple. If we change "L" of violet to 100, we will obtain magenta, which definitely belongs to Team Pink.

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

I like violet :D

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

Good luck & have fun to all participants!

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

Hope I can reach IGM lol

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

As a tester, hope you enjoy the problems!

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

as a Minecraft lover , I hope there is Minecraft in the tutorial

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

SpeedABforces

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

As a non Tester me happy ;)

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

Spent one hour just to realize that the answer for B is long long :v

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

I got AC for problem E one minute after the contest. I enjoyed the problems, thanks

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

As a participant, I will do my best and use all heuristics I know

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

I became CM in today's edu, where shall I register? div 1,2?

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

    Maybe you can register Div.2 now and take part in Div.2.

    Like changzhou, became Master but got negative delta in Div.2 :(

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

It would be cool to continue the tradition with photo of authors and coordinator:)

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

In Edu, many solutions to problem A, including mine, are hacked, because of set.

How is it possible? The time complexity is $$$O(t*n*(n-1)/2*4*log(4)) = O(5*10^7)$$$ which should not work longer, than 2 seconds.

I have solved ABCDE, and would become a master, if my solution to A wasn't hacked :(

Hopefully my solutions will not get hacked in this round.

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

Was the div2 registration intended to close this quickly? Almost 20 hours to go and "registration completed".

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

    Registration completed means u have successfully registered to participate in the contest, that doesn't mean that registration has ended for all.

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

      Oh, I don't recall clicking Register on that edition for some reason xD, must have done it before the announcement or something.

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

orz rui_er

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

久别无恙, Codeforces!

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

nutella, not LGM, testing.

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

Why did div1+2 collapse into div1,2?

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

I wish high rating to participants. Best of luck everyone.

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

GL&HF! Hope for high rating!

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

wow CN Round! Hope I can return home on time :D

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

Seeing "You" in legendary grandmaster colour felt so heartwarming even though I might never get there.

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

Wish get blue!!!!!

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

/bx rui_er and ruler,I'm Luogu Special_Tony.

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

Yet another Chinese round!

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

why this c is so difficult

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

    Going for D1 first before C might be a wise choice, because of its lower point value.

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

As a tester,I look forward to becoming Master.

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

may be in this contest I become a pupil or not. lets see!

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

Hope to get violet purple

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

just want to know what does the score distribution (1000 + 1500) mean?

two problems or something else?

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

I have participated in edu round yesterday and rating still not changed yet, If i participated in this round, my rating will change depending on my old rating?

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

Hope everyone will not get stuck in A, B and C.

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

If this round is hard I will be angry

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

As a Participants and who will enjoyed the problemset, I hope the problemset will be good :)

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

as a tester, hope you enjoy this round. This is certainly a very interesting round and I personally enjoyed it a lot, hope you guys have fun!!!!

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

My first ever Div 1!

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

希望可以解决一个题

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

As a problem writer who wrote rejected problem proposals, GL&HF to everyone!

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

If you like MO this much, you could try asking these on AOPS. That way, non-mathematicians can focus on coding! Leave us some problems!!!

Worst contest I have ever seen!..

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

Can someone answer this please — The rating changes of div2 participants will be made considering the performance of div2 contestants only or the performance of div1+div2 participants combined ?

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

i spent more time thinking about B2 than any of CDE.... I even had to use OEIS as a crutch for B2 (https://oeis.org/A063647 is the number of possible $$$y$$$ for each $$$x$$$) cause im too stupid at NT

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

Tfw I spend nearly two hours sitting in one place at D2. Always feeling so close, then turning out that I got nothing.

I'd appreciate a hint.

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

can anyone help me in c, i get correct submission (using binary search ) 258901211 but get 5 wrong submission by using the end value 1e12,1e14,1e15,1e18 . can anyone say the reason why only 1e13 get accepted

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

cool contest! how to solve E please?

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

Can we binary search on C div 2?

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

    Yep, use BS to find max of min in the list after purchase.

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

    you can BS what's the new minimum element after adding k cards

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

    Probably possible, but not necessary. You can straight-up iterate one time to distribute evenly so that we have $$$x$$$ minimum elements ($$$x \le n$$$), then iterate another time if after that $$$k$$$ is still positive.

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

    Yes, but not necessary. Wasted like an hour doing it. Then looked at implementation of top guys and felt really stupid.

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

    My approach didn't even consider BS. Just get the list sorted and then bump up the minimum with your coins to equal the 2nd lowest, then the 3rd, etc.

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

in div.2 D2 number of pairs(n, m) {n fixed, m unbounded} is equal to this OEIS A063647 but couldnt proceed further. did someone solve it by looking at this oeis?

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

    nah it's just some basic math deductions lol, not sure if my solution will fst tho

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

How to solve B2? The max I could reduce the problem to is that any pair $$$(a, b)$$$ must satisfy $$$((a / g) + (b / g))$$$ divides $$$g$$$ where $$$g = gcd(a, b)$$$, but I still have no clue how to actually count this faster than $$$O(n \sqrt{n} \log{n})$$$.

Also B2 >>> C in my opinion, it took me ~15-20 mins to come up with the overall approach for C while I was unable to get anywhere on B2 after 1.5hrs of thinking T_T.

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

    It should be reduced to count pair $$$(a, b)$$$ such that $$$(a+b) | b^2$$$

    You just need to prove that if $$$(a + b) | b^2$$$ then $$$(a+b) | gcd(a,b) b$$$

    It's actually enough to iterate over all factors of $$$b^2$$$ that no more than $$$b+n$$$

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

      The question is about the hard version, not the easy one

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

        Yes. I'm talking about B2. :)

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

          But if $$$(a+b)|b^2$$$ then the $$$a = 4$$$, $$$b = 4$$$ from the fourth example of B2 (which is confirmed to be a valid solution) won't work: $$$(4+4)/4^2 = 8/16 = 1/2$$$, this is not a natural number. Are you really sure?

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

    Let $$$a=gx, b=gy$$$ where $$$gcd(x,y)=1, g=gcd(a,b)$$$. $$$(x+y)$$$ divides $$$gy$$$, let $$$gy=q(x+y)$$$ or $$$qx=y(g-q)$$$, $$$y$$$ divides $$$qx \implies y$$$ divides $$$q$$$. Let $$$q=py$$$. So $$$gy=pyx+py^2 \implies g=p(x+y) \implies p$$$ divides $$$g$$$. Also note that $$$x<n/g$$$ and $$$y<m/g$$$. This allows you to check all pairs $$$(x,y)$$$ such that $$$gcd(x,y)=1$$$ and $$$x+y = g/p$$$ by iterating through all values of $$$p,g$$$. Overall time complexity is $$$\sum_{p=1}^{min(m,n)} \sum_{g=rp, 1<=r<=min(m,n)/p} \ min(m,n)/(rp) = \sum_{p=1}^{min(m,n)} min(m,n)/p = O(min(m,n)log(min(m,n)))$$$

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

    Here is how I solved B2

    Assume that $$$gcd(a,b)=g$$$ and let $$$a=gx$$$,$$$b=gy$$$ and $$$gcd(x,y)=1$$$. Since we need $$$g(x+y)$$$ to divide $$$g^2y$$$, we get that $$$(x+y)$$$ divides $$$gy$$$. So let $$$A=x+y$$$ and $$$B=y$$$. Here are few observations

    1. $$$A>B$$$

    2. $$$gcd(A,B)=1$$$

    3. $$$A$$$ divides $$$g$$$ giving $$$A\leq g$$$

    4. $$$gB \leq m$$$

    5. $$$g(A-B) \leq n$$$.

    Thus we get that $$$B\leq\sqrt{m}$$$ and $$$A\leq \sqrt{m}+\sqrt{n}$$$. So we can brute force on each $$$(A,B)$$$ pair which satisfies $$$1$$$ and $$$2$$$ and find the value of $$$g$$$ that ensures $$$3$$$,$$$4$$$ and $$$5$$$ by say precomputing multiples of every number.

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

    Maybe it is an easier way:

    let $$$s=a+b$$$, then $$$(a+b)|b \cdot \gcd(a,b)$$$ equals to $$$s| b \cdot \gcd(b,s-b)$$$, equals to $$$s | b \cdot \gcd(b,s)$$$.

    It meens that, for each prime $$$p$$$, let $$$p^{k_1}|b$$$ and let $$$p^{k_2}|s$$$, then $$$k_1 \ge k_2/2$$$.

    Calculate all prime factors of all integers, for each $$$s$$$, calculate the number of $$$b$$$.

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

I do really enjoyed this contest. Unfortunately, couldn't derive the formula for Div.2 D2 that would work with O($$$nlogn$$$) complexity

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

Out of curiosity, is there an easier approach than matrix expo to calculate the cumulative sums in Div1C?

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

    I solved it purely by observing the matrix. Took me a lot of time but managed to solve it using just prefix sums.

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

    It is actually a tree with depth less than $$$\log n$$$.

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

      Yes, but how do you count the number of times a node at depth $$$d$$$ is added to the current node?

      The recursive prefix sum value seems to be a linear equation of $$$d$$$ levels. I just gave up and used matrix expo to calculate the values in $$$O(\log^3(n) \cdot \log(k))$$$ time (the base matrix is just the lower triangular matrix, i.e, 1s for $$$col \leq row$$$).

      Then I just used these values along with the tree to calculate the answer.

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

        Simply write down on paper and notice that it is Pascal triangle.

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

        I strongly recommend you learn Generating Function! It is extremely useful!

        In this problem, let's write down a[1] a[2] a[4] a[8] as b[0] b[1] b[2] b[3] and see what happens if you do the reverse of $$$f$$$ in the problem statement. b will become b[0], b[1]-b[0], b[2]-b[1], b[3]-b[2]. And if we write down this array in the form of a generating function, it will be a transformation from $$$p=b_0 + b_1x + b_2x^2 + b_3x^3$$$ to $$$q=b_0 + (b_1-b_0)x + (b_2-b_1)x^2 + (b_3-b_2)x^3$$$, which turns out to be $$$q=p(1-x)$$$. If you do it for $$$k$$$ times, it will be $$$q=p(1-x)^k$$$. The coefficient of $$$(1-x)^k$$$ is simple.

        As you can see, generating function provides a clear and simple deduction towards the solution. Usually it is problem-agnostic, which means you can put anything involving counting (especially dynamic programming) into a generating function, and use math tools to solve it. You don't have to stare at the coefficients anymore. I got this solution using generating function withint 5 minutes.

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

    Yes, the $$$i$$$-th value is actually $$$\binom{k+i}{i}$$$. If you turn your head, you should try see a pascal triangle

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

      facepalm I observed the matrix of linear equations was the lower triangular matrix but somehow didn't realize this T_T.

      Thanks for the help!

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

        i did something even more stupid

        i knew $$$i$$$-th value is $$$[x^i] \frac{1}{(1-x)^k}$$$ then immediately went to do code that without thinking more 😹😹😹😹😹

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

      "if you turn your head" lol

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

      Too simple formula encourages guessing instead of solving, it is not cool.

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

Div2F is nice, implemented binary search part but couldn't to find minimum >= previous on x jumps in time.

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

I'm too bad at maths for this.. was so close to IM but now I'm back to low master cause I got hardstuck on NT lmao

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

:( :( :(

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

Mathforces.

Weak pretests. Maybe I can get positive delta with points earned by hacking.

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

can someone give me the submission of div2 C i checked my code at least 1000 times i couldn't find a mistake.

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

How to solve D1 div 2?

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

    First, you have to see that a must be a multiple of b. Then, it is a pretty straightforward (n+m)*log(n+m) implementation, where you iterate over all possible b and over all multiples of b.

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

    $$$a + b$$$ must clearly be a multiple of $$$b$$$. This is only satisfied when $$$a$$$ is a multiple of $$$b$$$.

    However if $$$a$$$ is a multiple of $$$b$$$, then $$$gcd(a, b) = b$$$, meaning $$$a + b$$$ must actually be a multiple of $$$b ^ 2$$$.

    So we have $$$a + b = k * b ^ 2$$$, or $$$a = k * b^2 - b$$$. So for each $$$b$$$, you can just count the number of multiples $$$k$$$ which generate valid values of $$$a$$$ in a total of $$$O(m \log m)$$$ or $$$O(m)$$$ time depending on implementation.

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

      can you help me understand how do we find that the time complexity is O(mlogm)?

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

    We are counting values of (a+b) which are multiples of b.gcd(a,b).

    e.g. (a+b) = k.b.gcd(a,b) (for some k values)

    dividing through b gives a/b + 1 = k.gcd(a,b)

    This means that a is divisible by b, e.g. let a = Xb, then gcd(Xb, b) = b

    Which reduces the problem to

    a+b is divible by b^2

    Iterate all b's, and look for how many b^2 fit beneath "maximum value of a" + the current b and sum them all up.

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

    You need to know two things for this.

    1) are you aware of "sieve of eratosthenes" ? What is the concept behind it ? What will be runtime complexity of it ?

    2) Reduce the formula



    => (a + b) % (b * gcd(a,b)) = 0, => (a + b) = k*(b * gcd(a , b) ) where 'k', is some random positive integer ( because => Right side is divisible by 'b' . So, left side also must be divisible by 'b'. => Left side, among (a + b) , 'b' is already divisible by 'b' ( obvious ) , so 'a' also must be divisible by 'b'. 1. Based on above, we know that 'a' is multiple of 'b'. Use two for loops, using sieve concept. complexity will be apprx O( n log n log n ) , considering modulo and division and multiplication occur in O(1).
    • »
      »
      »
      2 недели назад, # ^ |
        Проголосовать: нравится +3 Проголосовать: не нравится

      Why do you need SoE or something like that if ones just use the following piece of code?

      int count(int n, int m)
      {
          int k = 0;
          for (int b = 1; b <= m; ++b)
              k += (n / b + 1) / b;
      
          return k - 1;
      }
      
      
      • »
        »
        »
        »
        2 недели назад, # ^ |
          Проголосовать: нравится +2 Проголосовать: не нравится

        Same problem can be solved in multiple ways. my approach and your approach are different.

        My solution is based on what I did during the contest, I never claimed, that it is most optimised approach xD.

        I reducing the formula, I reached an observation, that 'a' must be multiple of 'b'.

        Now, for all 'b', within 1 to m, I will traverse through all possible multiples of 'b'.


        for(int i = 2 ; i <= m ; i++) { for(int j = i ; j <= n ; j += n) { f ((i+j) % i . gcd(i,j) == 0) ans++;

        To understand the time complexity I gave an example of SoE.Hope I have explained how I solved the problem.

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

mathforces

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

Am I the only one using Mobius Inversion to solve Div.1 B2? I spent almost an hour and couldn't find simpler solution. Also C<<B2

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

    Yeah being stuck in D2 made me lost rk1(Div 2). I spent almost an hour in it :(

    Actually when you found that $$$x+y | g (xg=a, yg=b, g=(a,b))$$$, you will realize that $$$(x+y)g \le n+m$$$ and $$$x+y \le g$$$ which means that $$$x+y \le \sqrt{n+m}$$$, so you can brute force every possible (x,y) and solve the number of g in about $$$O(n+m)$$$.

    BTW how to solve by Mobius Inversion I dont know lol

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

These are some good problems 💪💪🔥🔥

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

https://codeforces.com/contest/1972/submission/258921511

Can anyone pls tell what is wrong in this code for C?

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

B2 is restarted

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

My pre-contest predictions:

  • Math
  • Data structure
  • Implementation

Seems that all my predictions are correct!!

"Thanks" for such a round to let Chinese Rounds become stereotyped!!!

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

    Exactly.

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

    TheScrasse meanwhile I want too hear your voice about these Chinese style problems. I am wondering if these math problems are interesting for you, and the round is balanced with these problems.

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

      My take:

      • The only data structure problem here is 1967F - Next and Prev.
      • All the problems up to 1967C - Fenwick Tree have almost no implementation.
      • Yes, there is a lot of maths. But I prefer an unbalanced contest rather than a contest with bad problems.
      • In this contest, $$$26$$$ problems were proposed, and I didn't just accept a random subset of $$$8$$$ problems.
      • Most testers confirmed that problems looked good. Are there so many people who don't like this round?
      • »
        »
        »
        »
        2 недели назад, # ^ |
        Rev. 2   Проголосовать: нравится -33 Проголосовать: не нравится
        • Almost every Chinese round has a hard data structure problem(except ours).
        • I agree 1A~1C have almost no implementation. Those parts are enjoyable.
        • For math problems, what i dont like is handling these abstract numbers(some visualizable operations are more exciting) and processing very carefully with the corner cases.
        • Feedbacks are from Chinese\cup LGM. Is that really useful for most Codeforces users?

        edit: how can I forget the FST of problem D? Pretests seems to have n=m.

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

          About the last point: feedback is from the testers, which cover a wide range of ratings. In this case there was no big complaint from any tester. Maybe the testers overestimate the beauty of the problems?

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

          FST on D is just me being blind, seeing $$$5$$$ generators (with two of them which weigh 7 KB) and missing $$$n = m$$$. This is the second time I miss this detail, I hope the third time does not happen :(

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

    Always math :)

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

    Is stereotyping always harmful?

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

How to solve D2 (div. 2)? I've figured that x * y / (x + y) = n means (x — n)(y — n) = n ^ 2 and was trying to iterate through n, looking at all its divisors, getting divisors of n ^ 2 from it and trying to form all valid (x, y) pairs from it. But since n can get pretty large, O(max N * sqrt(max N)) takes too long.

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

    $$$a+b | b\cdot (a,b) \rightarrow g(x+y) | g^2y\space \space(let g = (a,b) ,x = a/g , y = b/g) \rightarrow (x+y)|gy \rightarrow (x+y)|g \space \space((x+y,y)=(x,y)=1)$$$

    When you found that $$$x+y | g (xg=a, yg=b, g=(a,b))$$$, you will realize that $$$(x+y)g \le n+m$$$ and $$$x+y \le g$$$ which means that $$$x+y \le \sqrt{n+m}$$$, so you can brute force every possible (x,y) and solve the number of g.

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

please find the mistake in this. Div2 C 258921994

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

Thanks for this contest, I really liked problem $$$C$$$!

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

If you submit the code casually, you even have a good chance of passing problem B and D1.

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

A question to anyone who solved div1C: does $$$\mathcal O(n\log^2 n)$$$ solution with the restoration of the value from indexes with a lower lowbit value to indexes with bigger lowbit values work?

UPD: the question is no longer relevant.

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

is my implementation wrong or does binary searching on number of perms not work?

my logic was that if you wanted X perms than array should be [X/n, X/n, ..., X/n+1, X/n+1] with X % n of them being X/n+1.

for some reason i get WA on pretest 2 so now i sad :(

258903132 258901827

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

Does my solution Can be hacked ? 258885731

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

Thank rui_er for giving a so easy CN Round.

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

Div. 2 B and C were literal guessforces. I spent an hour trying to find a solution to B, even wrote a brute force, then I viewed the samples and be like "Hmmmm... It's almost as if the U count is odd then Alice wins else Bob". And pretests passed... Whatever. Probably I'm just too retarded and it's actually very easy to prove.

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

    Yeah whenever you remove a coin, you always remove a U coin.

    There are three neighbour cases

    1. neighbours are both D, then U => U + 2
    2. Neighbours are both U, in which case U => U — 2
    3. One is U, one, is D, in which case U does not change.

    In all three, the parity of U does not change, so the only relevant fact is the parity of U.

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

      The problem statement says we should also remove the selected U. So it actually always changes to the opposite parity.

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

        My comment was perhaps not super clear. I refer to the parity staying invariant after you remove the first U coin, i.e. the neighbour transforms don't change parity, only the initial coin removal does

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

    i have gone mad after realizing the solution for B after spending an entire hour.

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

    The brute force also passes 258885731

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

how have so many people in Div2 solved D2?

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

what is the optimal rearrangement of the the 6th test in Div2 C test samples ?

I tried a lot during the contest to figure out what is the best rearrangement but I couldn't find it :(

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

    If you meant this testcase:

    9 7
    7 6 1 7 6 2 4 3 3
    

    Then it's as of following:

    • Add $$$a_3$$$ by $$$3$$$.
    • Add $$$a_6$$$ by $$$2$$$.
    • Add $$$a_8$$$ by $$$1$$$.
    • Add $$$a_9$$$ by $$$1$$$.

    Then we get:

    7 6 4 7 6 4 4 4 4
    

    Now, one possible arrangement might be:

    1 4 2 5 3 6 7 8 9 1 4 2 5 3 6 7 8 9 1 4 2 5 3 6 7 8 9 1 4 2 5 3 6 7 8 9 1 4 2 5 1 4 2 5 1 4
    

    ($$$46$$$ elements in total, valid subarrays are $$$[1, 9], [2, 10], \dots, [32, 40]$$$)

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

I hope there will be a plagiarism check for this Round, since apparently the solutions to Div 2 A, B, C and D1 were leaked hardly an hour into the contest.

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

    a, b, c were all brute force that even 800's can solve. I dont think it is necessary to check plagiarism for them

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

      Nope, never. Regardless of the difficulty of the question, plagiarism is a serious issue.

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

I can't call myself a mathematician anymore :(

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

Thanks for Interesting problem and positive delta~~

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

Anyone knowing in how much time aproximative the ratings will be out??

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

Why A is failing on systest?

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

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

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

CNOI Round 🤓👎

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

In div2 on D2 we have 588 accepted solutions. In div1 on B2(same task) we have 582 accepted solutions.

funny :)

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

why D1 is so easy may be some other problem can be placed at D and D2 can be a different problem

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

There seemed to be a weak pretest in C? 4000AC->3600? And I seemed to fly about 100 rank:)

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

    Yeah, also jumped a bunch of places up. But then again, you're responsible for verifying your solution even if you managed to pass the pretests.

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

    Yup. I made the upper bound on answer smaller than it actually is, giving WA on test 9. Tbh sucks going from +30 to -100 delta.

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

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

lol, i spent like 40 min trying to solve B, because i didn't double check examples , and i didn't read n coins on the table forming a circle

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

Could you please give me testcase of problem C div 2. I got WA but I don't know why.

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

was it rated?

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

day by day div 2 is getting harder for me :)

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

I have made detailed video explanations for C and D1 Question Here are the links for anyone who wishes to watch

C : https://www.youtube.com/watch?v=ZP4HPYTWtZQ D1 : https://www.youtube.com/watch?v=cSKooXv7FKA

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

Finally a div.1 standing with tourist rk1 and jiangly rk2! BTW, congrats to Kevin!

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

amazing problems! However math problems are a little more than I expected,which I'm not good at.

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

Why more and more gcds?They are not interesting!!!!!!!!!

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

please provide an update on when the rating will be updated?

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

I found myself waking up six times throughout the night, hoping to see my new 'Max Rating,' yet it remains unchanged even now!

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

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

Is it rated?

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

Is there any issue/delay in updating rating of this round?

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

Did anyone try to prove the solution div2 B? I think we get the pattern pretty quickly, but proving it is not intuitive. How do we prove that with induction?

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

    At every turn, the parity of the total number of 'U' cards flips. This is because once we flip a 'U' card, the number of 'U' cards decreases by 1. Now since it has two neighbours , it will be either a). DD -> UU b). UU -> DD c). UD -> DU

    Either the number of U increases by 2, decreases by 2 or remains same. Since we already discarded a U card, the parity always flips. Also since the maximum number of U can be the current size of the string, we can guarantee the game will end at most after n turns. The winner of the game is the person who gets the string with only 1 U left. So we can conclude that whoever starts with odd number of U's will be the one who will get to the state where there is 1 U left, and hence will win the game.

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

      got it thankyou.

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

      I couldn't prove it too ,just discovered the pattern through test case,but couldn't understand the gist of the problem.

      Can you tell me who will win for this case"UDU" ?

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

Was this contest unrated?

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

Over a day and wasn't rate. Why??

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

And finally, it's rated!

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

tourist is back on top againnn

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

in this contest there again those (before some of them i already mention in previous contest where they failed the system test for a problem)tried to change there code and may happen that they might be undetected so posting this (majorly they tried avoiding a bit by looking at the format of i(i+j) and just trying to be smart let them be declared as a variable instead of using directly and all the necessary loops needed in submissions of D2 div2: 258918241 258918681 258918681 258917636 258918237 258917628 258918431 258917198 258917154 Vladosiya MikeMirzayanov

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

《久别无恙》

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

nazmulaas2023 is my second id....on this contest..by mistake of mine i submitted my code into nazmulaas2023...that's why my code of nazmulnns2066 and nazmulaas2023 is same...unitentionally i did this...please consider..i apologise for this mistake

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

i made a mistake during the contest..i submitted C in my wrong id which is nazmulaas2023..when i realize this...i change some of the code and then submitted in my id nazmulnns2066 which i did the contest..that's my code look similar.. i apologise for my mistake..

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

sorry MikeMirzayanov, but the system declare that my 1972C submission is similar to huanjua. My explaination is we are both students come from Ho Chi Minh City and in 2015-2016 entrance exam in VNU.HCM for grade 9 there is a problem using the same binary search idea and we use the same idea. Please give me back my rating. Thanks