Блог пользователя manish.17

Автор manish.17, 17 месяцев назад, По-английски

Hi again, Codeforces!

fishy15, flamestorm, ScarletS, saarang and I are glad to invite you to our second Constructiveforces round, Codeforces Round 836 (Div. 2), which will be held on 25.11.2022 18:35 (Московское время). The round will be rated for participants with rating lower than 2100.

Please note the unusual time!

We'd especially like to thank:

You will have 2 hours to work on (and solve!) 6 problems. At most one of the problems will be interactive. Make sure to read this blog and familiarize yourself with these types of problems before the round! You are highly encouraged to read all the problems ;).

The scoring distribution is $$$500-1000-1500-1750-2250-3000$$$.

Good luck, and see you on the scoreboard!

UPD1: Thanks to ak2006 for making video editorials for some of the problems.

UPD2: Editorial is out!

UPD3: Congrats to the winners:

Div. 1 + 2:

  1. jiangly
  2. SSRS_
  3. kotatsugame [tie]
  4. Maksim1744 [tie]
  5. March_7th

Div. 2:

  1. March_7th
  2. is_this_Furry
  3. puffins
  4. DongXuelian
  5. ouqI
  • Проголосовать: нравится
  • +95
  • Проголосовать: не нравится

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

omg saarang round

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

OMG the moment has come. The best round ever is here. I really enjoyed a lot testing it, I'm very proud of y'all, you're great problemsetters ;) Hopefully you'll enjoy it as much as I did.

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

oh eem gee guysss!!!? how did saarang, a blue coder set a div2????⊙_⊙?? im literally shaking and crying in disbelief..!

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

    oh eem gee guysss!!!? how did tibinyte, a Leafeon. coder set a div1????⊙_⊙?? im literally shaking and crying in disbelief..!

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

As a tester I can assure you that the problems have very good quality and are fun, you can't miss the opportunity to participate in this contest :)

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

As a tester, I'm sad because I can't participate

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

Among us

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

"At most one of the problems will be interactive." That feeling when the number of interactive problems is in the range of $$$[1,1]$$$

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

As a non non-tester I have not not tested and the problems were not not good.

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

As a tester I must say that one of the authors, namely ScarletS, has a huge skill issue when it comes to Codenames.

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

    As an author I must say that one of the testers, namely AlperenT, has a huge skill issue when it comes to Codenames.

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

As a tester, I must say that atodo and AlperenT are the most based codenames spymasters ever.

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

omg saarang round

»
17 месяцев назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится
Meme
»
17 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

When there are multiple problem setters, how do people decides who makes the announcement post and gets the contribution? Coin toss may be?

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

seemed like a joke but not.

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

omg indian round

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

As a tester, atodo didn't test.

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

As a Tester please give me contribution.

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

thanks for the round

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

manish.17-fan-club

»
17 месяцев назад, # |
  Проголосовать: нравится -20 Проголосовать: не нравится

I hope the constructiveforces part is a joke

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

As a tester

»
17 месяцев назад, # |
  Проголосовать: нравится -38 Проголосовать: не нравится

The round clashes with Ecuador vs Netherlands, can it please be postponed?

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

As a tester, this round was pretty fun to test. Hope the same holds for participants too!

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

Hope this round will make expert.

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

Note the unusual timing.

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

As a former POTUS, I sure hope this round is good.

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

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

This is my first round . Good luck to everyone :)

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

    Do you have any previous history in competitive programming? I mean do you participate on other websites?

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

Hope to get to Master.

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

Please note that this contest (div 2) is start from an unusual time!

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

    Yeah. It's written in bold in the announcement. No need to put useless comments down here.

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

Good luck to all participants of this round, hope to positive delta

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

Good luck everyone! Time to grind

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

omg Ali_ZaiBug round

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

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

omg Ali_ZaiBug round

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

omg Ali_ZaiBug round

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

SpeedforcesAB

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

Samples are quite nice. ;)

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

Contest=Xor

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

Cool, unorthodox problems. Good job and thanks setters! Had fun.

»
17 месяцев назад, # |
  Проголосовать: нравится -35 Проголосовать: не нравится

I really hate constructing sequence problems, and no one can convince me that these types of problems are useful for competitive programming. They are basically hit or miss. Shit problems!

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

There was hardly any implementation before E ...

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

Constructive Round ^^

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

Div1Forces

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

Any hint for D?

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

    Take the sum of the sequence to be $$$k^2n^2$$$ and then take the elements of the sequence to be $$$a, a+1, a+2, \dots, a+\frac n2 - 1$$$ along with $$$a+kn, a+kn-1, \dots, a+kn-\frac n2 + 1$$$ for some $$$a$$$. (I know I've added an extra term if $$$n$$$ is odd, feel free to remove it from either side) Now try to find ways to determine the value for $$$k$$$ and $$$a$$$.

    Hint 2: Consider cases where $$$n$$$ is even and odd seperately.

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

    Solution for D:

    If $$$n$$$ is even:

    Let $$$\Sigma a[i]=n^2$$$.

    $$$a[]=...,n-2,n-1,n+1,n+2,...$$$.

    Sample:

    $$$n=6$$$

    $$$a[]=3,4,5,7,8,9$$$

    If $$$n$$$ is odd:

    Let $$$\Sigma a[i]={(n+1)}^2=n^2+2n+1$$$.

    $$$a[]=(n-n/2)+1,...,(n-2)+2,(n-1)+2,n+2,(n+1)+2,(n+2)+2,...,(n+n/2-1)+3,(n+n/2)+3$$$.

    Sample:

    $$$n=5$$$

    $$$a[]=4,6,7,9,10$$$

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

how to solve B what's the idea ?

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

for problem C if n%k != 0 then we can't form a permutation . but or we can simply place n in kth index and we'll be done

why wouldn't this work anyone ?

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

    Take for example 8 2

    Your method would give 2 8 3 4 5 6 7 1

    But I can also construct 2 4 3 8 5 6 7 1 which is lexicographically smaller due to having 4 instead of 8.

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

    This is not the lexicographically minimal solution For example n=12,x=3 you can form a_3=6,a_6=12, others equal to i

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

    The statement asks you to get the smallest lexicographical answer.

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

I submitted 5 sec before for Q3 but it said that contest over can you kindly accept the solution. Since it didn't compile in time it didn't accept

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

The problems were really fun!

However, I suspect the solutions for A,B, and C were leaked. While hacking, I noticed a bunch of grey coders with the same mistake in C: returning -1 if n>>16 == x, which doesn't seem related to the problem at all. This fails for testcase

1
199998 3
»
17 месяцев назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

Is this Construct forces? What is your fetish with construct the sequence folks ?

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

ConstructiveForces

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

Similar but not same problem for E: here

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

Nice round thanks!

I will agree with other people that ABCD all being constructive is slightly boring, but I would rather have 6 good constructives than 6 varied but mediocre problems (also I guess im slightly biased lol).

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

When will upsolving be opened?

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

Nice contest of constructives Thx for this amazing contest.

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

For those who are unable to solve C, try finding the ans for n=60, x=2

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

For the problem D, I got the answer when n is even , but for the odd n , I tried a lot but didn't get. I was trying to use the seq: (sum of 1st n odd numbers ) = n*n , and to maintain the max-min diff, I manipulated this odd numbers sequence like I made this diff to be equal to n so that n*n matches with the sum but failed when n is odd , in this case 1 value was always repeating. Can someone please help for odd n.

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

my solution for D:

if n is even, let say max — min is 2n then we can have half 5n and half 3n, if you do the sum it is exactly 4n^2. 5n * n/2 + 3n * n/2 = 4n^2 = (2n)^2.

if n is odd, we can compute for cases where n >= 7. add another 3n and reduce 3n from the 5ns. Sum is still 4n^2

if n is 3 or 5, then just find some cases that work. Example already has case 5.

To make number distinct just add minus from the first half, and add the same thing in the second half. They are guaratee to be distinct because 5n and 3n is a large range and we only have n/2 numbers This solution is very tedious. Is there a better solution than this?

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

    There is this. But I don't think it's pretty.

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

    I solved D by two pointers technique about min and max of array.

    Let's call the minimum and maximum of $$$A$$$ are $$$m$$$ and $$$M$$$, respectively.

    Then the minimum sum occurs at [ $$$m$$$, $$$m+1$$$, $$$m+2$$$, ..., $$$m+N-2$$$, $$$M$$$ ], and the maximum sum occurs at [ $$$m$$$, $$$M-N+2$$$, $$$M-N+3$$$, ..., $$$M-1$$$, $$$M$$$ ].

    Hence,

    $$$ \dfrac{(N - 1)(2m + N - 2)}{2} + m \le (M - m)^2 = s \le \dfrac{(N - 1)(2M - N + 2)}{2} + M $$$

    where $$$s$$$ is the sum of $$$A$$$.

    So run a while loop until find the inequality above met. In each loop, increase $$$m$$$ by $$$1$$$ if $$$(M - m)^2$$$ is lower than range, or increase $$$M$$$ by $$$1$$$ otherwise.

    After finding $$$m$$$ and $$$M$$$, it's easy to find the solution. (Just equally increase the elements of $$$A$$$ starting from the minimum sum case, until the sum meets $$$(M-m)^2$$$)

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

Sir, prease give my rating beck. What do I have to do with your nonsense?

Deepesson You give my rating back imediately

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

https://codeforces.com/contest/1758/submission/182524851 I literally can't find what's wrong in my solution, can anyone please show why this solution is wrong?

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

Yeah, it was very good, i like it

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

Can some please explain to me why my solution — 182545721, is giving a time limit exceeded error? While this solution is not 182533564.

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

my solution for C :

If n%x != 0 then there is no answer, else p[x]=n. Let j be the current index of n in the permutation, iterate from x+1 to n-1 and , when you find an integer i such that n%i == 0 and i%j==0 swap(i,j).

Unfortunately the solution is wrong, can anyone help me find the mistake ?

Submission : https://codeforces.com/contest/1758/submission/182515365

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

    You have to set $$$p[n] = 1$$$ at the end after $$$p[x]=n$$$, otherwise you are overwriting it when $$$x == n$$$

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

      the case where n==x is handled by the if statement already

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

        you're right, your problem is the break, you should have pushed more the n to the last position you could so that the solution is lexicographically the smallest

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

          OMG it was never intended to put it there, I forgot to delete it after changing the solution. OMG that's tragic. Thank you for your help!

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

    It’s not a “solution”, if it’s giving wrong answer

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

      It is indeed a solution, I just made a mistake while coding it (forgot to delete a break statement). It got AC in the end.

»
17 месяцев назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится
Meme
»
17 месяцев назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

Screencast with commentary

Also, problem E should not appear in rated contests.

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

    Why?Is it because there is a known problem very similar to it?

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

      Yes, this is a very well-known setup, and there wasn't any new spin on it.

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

Feeling sad that I almost solved d but couldn't able to submit within time otherwise it was very good contest as per my side!!! My problem D sol.n: 182548322 It was random approach i get to by trying some no.s i get that for every n , 2*n + 1 could a valid difference of maximum of a[i] — minimum of a[i]. If you know the explanation pls let me know!!!

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

Alternative solution for D

It works only for $$$n > 3$$$, so cases then $$$n=2$$$ or $$$n=3$$$ should be solved by hand (or bruteforce)

It is well known that $$$1 + 3 + \dots + 2\cdot n - 1 = n^2$$$ and $$$max - min$$$ in this case is equal to $$$2\cdot n -2$$$.

Let's decrease second and third numbers by 1 and increment last number by 2, so we will have: $$$1,2,4,7 \dots 2\cdot n-3, 2\cdot n+1$$$ and now $$$max - min = 2\cdot n$$$.

How to get the sum equals to $$$4\cdot n^2$$$? We can add $$$3\cdot n$$$ to every number!

Thus, we have $$$sum = n^2 + 3\cdot n \cdot n = 4\cdot n^2$$$ and $$$max-min$$$ will not change.

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

This channel leaked ABC during contest. Can we find all the cheaters who copied problem C and just perma ban them? Close to 1k views on problem C

https://www.youtube.com/watch?v=vGpNQQo-NPI

I think their solution C is unique enough to id the cheaters

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

    @MoreAnyNot really? I'm asking myself how do you know that? Maybe you submitted it yourself?

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

Really nice problem E.

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

I don't understand why problem D was included in the contest especially at the rank of D and the cut off point for most participants, it doesn't take any algorithm to solve nor can any interesting observations be made. otherwise great contest.

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

Loved the contest, thinking 1,3 in problem B was helpful. Saw C, tried, failes :D.

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

Please help me figure out what's wrong with my C https://codeforces.com/contest/1758/submission/182541955

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

    Why do you think multiply only by 2 is enough? x=3,n=27 will hack your solution. Output isn't even a permutation.

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

Simple greedy solution for D:

  1. To give ourselves a bit of wiggle room let Max-Min be equal to 10*n, Then let the square of this expression be x
  2. Initialize the array from 1 to n as you normally would with a[i]=i for 1<=i<=n-1 and a[n]=1+10*n, let the cost of this initialization be MIN .
  3. Then we can increment every element by 1 and reduce the leftover of x by ((x-MIN)/n)*n.
  4. Now we can greedily spend the rest of X incrementing elements starting from the back.

it is easy to see that 10*n difference is more than enough because after step 3 x will be strictly less than n which is less than the difference between the sum of numbers from (10*n-n+1, 10*n-n+2..., 10*n); — (1, 2..., n).

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

Maybe it's impossible for an expert to solve only 2 problems during Div2, but today i realized it. Thanks to this round, I will practice more to improve myself. :)

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

    I don't think it's an indication of how good you really are at solving problems. Indeed, no one expected so many constructs in a row

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

Finally, Candidate Master, thank you for the contest.)

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

Problem description was very short and clear. I like it. Problem set was also logical and efficient. Just wow round.❤️

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

Reached expert with master performance today. Thank you for the constructiveforces round.

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

Please consider that their is a YouTube channel that post the problems code during contest time https://youtu.be/vGpNQQo-NPI

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

182612492

can anyone tell me why i am getting runtime error! i tried with prime factorization and swapping

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

    Line 19. p -= p // i looks wierd. Shouldn't it be p = p // i ? As a result, list b contains much more numbers than it should, thus you get index-out-of-range error later.

    Edit: Fix this error and get accepted.

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

What is expectation raitong for C and D

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

Hi ,this contest had a different style than other codeforces contests. Other codeforce contexts are more algorithmic. But this contest had a more creative style. If this style of contest is going to be held again, please have its own type. Thankful

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

An awesome round it was.