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

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

Hello, Codeforces!

amurto and I are glad to invite everyone to participate in Codeforces Round 838 (Div. 2), which will be held on 15.12.2022 17:35 (Московское время).

This Round will be rated for participants with rating strictly lower than 2100. Participants from the first division are also welcomed to take part in the competition but it will be unrated for them.

You will be given 7 problems and 2 hours and 30 minutes to solve them. One of the problems will be interactive. Make sure to read this blog and familiarize yourself with these types of problems before the round!

We would like to thank:

Score distribution is 500 — 1000 — 1750 — 2000 — 2500 — 2750 — 3500.

UPD1: Congratulations to the winners!

Overall:

Rated:

UPD2: Editorial is out.

We are looking forward to your participation!

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

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

Really awesome problems that I enjoyed testing very much. Highly recommended to participate (and up-solve :P)

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

As a tester, this is truly one of the rounds of all time.

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

    brobat orz

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

    A, B, and C are truly amazing. D got fewer solves :-( in this round.

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

      Can you explain your approach for B

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

        sort the array; start making each element a multiple of previous;

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

        Just try to make all numbers (let num be 'x') equal to nearest power of 2 which is greater than or equal to 'x'. And with little observation you will be able to conclude that the nearest power of 2 (let it be 'y') such that it is greater than or equal to 'x' will always be lesser than 'x' i.e. y — x <= x. This way you don't need to sort the array or use any vector.

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

          That's nice, btw one can immediately see the fact if you represent $$$x$$$ in binary. If $$$i^{th}$$$ bit is the msb, then, then after adding $$$2^{i}$$$ (note that $$$2^{i} \le x $$$) the number becomes $$$ \ge 2^{i+1}$$$. So, after adding some stuff which is $$$\le x$$$ we get a number that's higher than the next power of two. So, its proved!

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

        make every element equal to power of 2

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

As a tester master, I am the master tester. First round I tested, orz problems!!

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

    As a tester newbie, I am the newbie tester. Second stack round I tested, orz problems!!

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

Cool problems, I recommend taking part.

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

As a tester, Good luck to everyone who will participate

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

As a tester, I can assure you all will have fun in solving problems.

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

As a tester, I have enjoyed testing this problem set and all of the problems are really high quality

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

As a tester, I hope you'll enjoy the problems as much as I did! Yet another well-coordinated round by errorgorn :)

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

Please participate

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

As a tester, I highly recommend reading all the problems.

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

blog of #838 posted and there's no editorial for #837

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

As a tester, I didn't really tested the problems

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

As a tester, the round is awesome!

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

I see more comments from testers than from others, so I am also adding mine to increase the count XD.

PS: Problems are really good and one can look at stack's previous round to see his problem quality.

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

As a discusser of problems while proposal was in review and a tester, please let me participate

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

As a tester, so huge number of the testers...

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

As a tester, I really enjoyed testing this round. I solved some of the most enjoyable problems yet!

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

As a participant, I haven't tested the round yet. Really awesome problems that I enjoyed. I recommend this round for everyone.

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

As a participant its scary to have so many testers, I hope everyone may achieve Δ ≥ 0 :)

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

As a non-tester I can assure the problems are of high quality.

Source:- Trust me bro.

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

As a tester and an ex-tester, my assertion still holds true.

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

I think it will be interesting to solve this contest

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

    it will be nearly impossible to solve contest by us(whole questions),but yeah we can try to solve 3-4 questions.

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

As a tester, it’s a(Good) round ^_’

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

hope to gain more rating which i have lost in previous two contest.

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

As a nothing, this is truly one of the best contests.

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

why rating of previous contest is not updated yet??

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

I have never seen this many testers in any div2 contest.

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

Will the rating of educational #139 be updated before #838 starts? If not, rating of educational #139 will be updated based on the rating after #838…

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

Stack and Amurto Round. 🛐
Very excited for this contest.

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

When ratings will change?

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

When ratings will change?

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

After a long time. Best of luck Everyone.

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

RETURN MY RATTTTIIIINNGGGGG

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

When will the Ratings change for this round?

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

2 recent contests, someone can do this Meme

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

There is a list of allowed languages in the announcement Email:

C/C++, Pascal, Perl, Java, C#, Python (2 и 3), Ruby, PHP, Haskell, Scala, OCaml, Go, D, JavaScript and Kotlin.

I don't understand why do you limit the programming languages contestants can use? E.g. why can't I use Rust?

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

    I support you. I myself practice a bit in rust, and there's no reason to exclude it in my humble opinion

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

Is Perpetually_Purple suffering from success because now he is not "Perpetually_Purple"?

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

Argentina vs France suiii

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

oh no , 1750 points for problem c

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

Hi, I'm new to programming so was wondering, when the contest means it will start at 8:35 AM, does that mean we have to start coding at 8:35? Or can we start anytime after that?

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

    This game is from 8; 35 to 10:35,You can compete at any time during the two hours of the competition, but I suggest you enter at the beginning of the competition, otherwise your competition ranking may be lowered a lot.

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

All the best everyone

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

Good luck to everyone!

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

I think the interactive problem is C

**Do u agree that ?** 
»
17 месяцев назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Hey, Can anyone help me? I am a starter in cp, which div is suitable for me?

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

    The higher the Div number, the easier, so Div 4 is the most suitable for a newbie. However, this doesn't mean you should only do Div 4 contests. I encourage you to try ALL contests, but just keep your expectations realistic.

    If you're at a point where you cannot solve even the first problem in Div2 during the contest, try to aim to solve at least the first problem. If you're at a point where you can only solve one problem in Div2 during the contest, then try to aim to solve two problems, or at least try to solve the first problem a little faster and/or with fewer failed attempts. And so on.

    As long as you keep your expectations in check, you should be able to benefit from every contest, as long as you utilize them effectively as a learning experience instead of only trying to hope for a miraculously high ranking.

    But if you have time management concerns, e.g., you can only afford to put aside time for one contest in the next few days due to being busy with other work, then you should probably just stick with the easier contests for now, i.e. join the Div3 in a few days instead.

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

    Div2,3,4 is suitable for you. Participate on those divisions contest regularly.

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

Hope to get to cyan :(.

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

Interactive problems, the worst thing that happened to Codeforces.

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

    You can't just say it's bad because you are not strong enough to solve it :D.

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

It's better to take a break from prime-factorisation problems this time

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

Good DP in Problem C

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

Yeah binary strings are so fun that I cant stop enjoying them

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

It was cursed for me :(

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

difficult round (•_•)

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

hoping for a color change to cyan :-) Let's see

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

Div.1 + Div.2... Not enjoyed this one tbh...

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

Is there randomized solution of D or something else?

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

    I try to use the conclusion that 0 is the only number that leads to distinct gcds when gcding with other numbers, but failed.

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

    You can take three pointers i,j,k (initially 1,2,3) and ask query for i,j and j,k and say u get the input as x and y respectively. If x>y, you can increment k to max(i,j,k)+1, else, if x<y then i = max(i,j,k)+1 else j = max(i,j,k)+1. So in every two queries, you are discarding one element of the array for which you are sure that it isn't equal to 0 and you have to dicard n-2 elements in total, so this will take a total of 2(n-2) queries.

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

Cannot come up with D and I'm about to get negative delta

any idea?

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

    query for(1,j) where 2<=j<=n and if(p1==0 || p1>=(n+1)/2) we can solve

    let query(i,j)=gcd(pi,pj)

    else we know p1=max(query(1,j)), if p1>1, we can deal with {j|query(1,j)==p1}

    but if p1==1 what can we do next

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

    You can see here.

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

      Oh I see thanks

      I only thought about "how to find a number >=(n+1)/2 in n queries"

      However the answer is "how to find a number !=0 in 2 queries"

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

    also I think interactive problem should appear at least E...

    D is a little bit early

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

i don't know why my D is wrong i am so frustated :( debugged for almost an hour but could not find mistake!!

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

    Similar. I have theoretical proof for time limit and correctness of my algorithm which means i made some stupid mistake in code and just could not debug it ;-;

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

      That's because the first number you picked can be 1 in which case the list of potential indices will reduce only by 1 instead of being divided by some number >=2.

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

DEFG are too hard. :(

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

Hint for Problem D?

The best I could come up with is the observation that 0 will never give the same GCD against two different values (a property that only 0 has), but I couldn't figure out how to hunt 0 down from there...

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

    you take 3 indices a, b, c:

    if gcd(a, b) == gcd(a, c), it means that a is not 0, thus you remove a.

    if gcd(a, b) > gcd(a, c), it means that c is a "divisor" of a, thus you remove c.

    if gcd(a, b) < gcd(a, c), it means that b is a "divisor" of a, thus you remove b.

    you make 2 queries for removing 1 element, total number of queries equals (n — 2) * 2

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

      Thanks bro

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

      nice solution !! it seems so simple and you explained in 3 lines!

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

      let a=24, b=18 and c=20 then gcd(a,b)>gcd(a,c) but c is not a "divisor" of a. I guess the actual reason is since gcd(a,c)<gcd(a,b), it implies gcd(a,c)< a hence c is not 0 and can be removed.

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

        you're right, I didn't know what to call it. I came with that Idea from the fact that if b is 0, the gcd will always be greater. So the real reason would be if gcd(a, b) > gcd(a, c), it means that c is not 0.

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

    one obsrvation is that for A[i] > (n/2) -->it give gcd = A[i] for two places himself and with 0 two indicies for this can be found in O(n) iteartion

    This only if choosen is >(n/2)

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

whenever, there are too many testers saying the round is one the most interesting rounds. Don't take them seriously.

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

Am I really not seeing something, or is C really addition of nC0 + nC1 + ... + nCk, where k is the amount of '0' or '1' depending on the last digit? If that's the case, how can I calculate it in O(n) or O(n log n)?

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

    It's sum of 2^(number of continuous digits in suffix) for every i

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

    I did it using dp. if s[i] == s[i-1] , dp[i] = dp[i-1]*2 else dp[i] = 1.

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

    No, it's a lot simpler.

    Let's say you have a prefix of $$$k$$$ 1s. Then every extension is valid, i.e., there are $$$2^{k - 1}$$$ possibilities. You can watch for the chain and double the number of possibilities at each step. A prefix of $$$k$$$ 0s is symmetric.

    But now, let's say at some point the string changes, e.g., from 1 to 0. Up to the 1, the majority must be 1, so in order for the majority to change to 0, the next value must be 0, and there is only one possibility. This resets the chain. If we follow it up with another 0, we are now back to having the freedom of 0 or 1 in between, so the chain (which we just reset) now grows in the same way as before.

    tl;dr — separate the string into blocks of 0s and 1s. For each block of length $$$k$$$, add $$$2^{k - 1}$$$ to the answer.

    My submission: 185325238

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

      facepalm I read the question wrong and thought that a good substring only need the final median to be good... Then I started to look at Pascal triangle and all those stuff...

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

        Feels good that I am not the only one who did it. :(

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

        I just made the same mistake and misread the problem statement and tunnel visioned... I was also wondering how to solve for nCk sums fast. I guess I should learn to read problem statements more carefully

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

    I also stuck here :)

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

It's too hard. Div.1 + Div.2?

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

The problems are good, but my condition is not good. I have used more than 1 hour thinking about strange algorithms, which lead to insufficient time to finish F.

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

How do you solve D? My idea ( that almost solves it) is to keep track of candidates. Take a random number and check gcd with all the caniddates. The new candidates will be the caniddates with highest gcd because they are the multiples of the inital number (and dont add the inital number to the new candidates), and since zero is a multiple, it will be among the candidates. The number of candidates at worst case decreases by half so the number of queries is n * (1/2 +1/4 +1/8 ...) < 2*n. The only problem is when we happen to start with one. Then we get another n queries and we make 3*n queries.

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

    I found one approach which keeps a track of exactly 3 candidates each time and asks 2 queries to eliminate one; you can use this as a hint or check here.

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

    I did this solution and solved the problem with 1 by first picking two indexes and checking them with every one else (in random order) "in parallel" (i.e. gcd(x, 0), gcd(y, 0), gcd(x, 1), gcd(y, 1), gcd(x, 2), gcd(x, 2)). The moment I get the first non-1 I know that this was not "1" and continue as you described.

    By randomizing index order the expected number to get the first non-1 seems to be "quickly enough", though I'm not sure what are the actual odds (i.e. if we happen to randomly pick x = 1, y = 2 and then the ordering happens to try to check it with 2, 4, 8, 10, ... first it can probably break). But it just passed final tests, so I guess it's fine.

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

DDDDDDDDDDDDDDDDDD!!!!!!!!!!!!!!!!!!!read 1 or -1???!!!!!!!what!?

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

The judges were very kind

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

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

Here's my solution for D

Maintain a list of potential index that could be 0, let's call it v, query v[0] against v[1], v[2], ..., v[v.size() — 1], we can see that if query(v[i]) = max(query(v[1...v.size() — 1])), v[i] can either be 0 or multiple of v[i], remove all v[i] != max(query(v[1...v.size() — 1])), repeat

If there is exactly 1 query(v[i]) = max(query(v[0...v.size() — 1])), let's call that v[i] is vmax, then either v[0] or vmax is 0

Run this until size of v is <= 2, we have our answer! Also, if gcd(v[0], v[1]) = gcd(v[0], v[2]) = 1, v[0] couldn't be 0, so remove it

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

    what do you do when v[1] is 1? wont you make n queries without narrowing down the potential indices? couldnt figure out what to do when the first element is 1 :(

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

      you can remove 1 from the first 2 queries

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

        You don't really remove the 1 this way. But it works nevertheless

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

          Why swishy123's exact solution is failing on test case 26. May be some new test cases are added.

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

            wait, so i just got EXTREMELY lucky lol, i think the new test cases is the test people managed to hack others with

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

              I don't get why your idea doesn't work. You keep discarding one element with two queries until you find an element that is not one. Say you have discarded m elements. The total number of queries your code will make is 2*m + 2*(n-m) = 2*n

              I fixed my code with your idea (I didn't know how to get an element that is not 1 during the contest) and it gets AC. 185457951

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

    I did it but got WA on pretest 5. Just could not debug the code the whole contest ;-;. Edit — Actually got query limit exceeded.

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

    \worst case, queries = n + n/2 + n/4 + ...

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

A -> D is pretty easy :D but dunno why my F is RTE >:(.

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

fast coding forces be like

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

Why not prepare this contest as div.1+div.2? I think it is too difficult for div.2. Or maybe arc is anothor good choice, Uh?

Afterall, problems are nice.

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

Wasted a lot of time trying to solve D before even seeing C, but great round with interesting problems nonetheless.

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

    I found D easier than C and solved it before problem C. Or at least it's more beautiful

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

this guy https://mirror.codeforces.com/profile/jiangly is amazing. Solving problems within 1 minute.

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

A really great round with good problems !

Thanks a lot!

I hope all the upcoming December contests would be like this :)

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

What? A contest without successful hack? Maybe problems are too hard and no one has extra time for hacking?

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

Awesome num theory forces.

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

What was the idea for problem E? Was there a combinatorics formula or some constructive algorithm?

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

    For a fixed tree the weights are also fixed. The proof is to just delete the leaves until the whole tree is deleted. In fact, $$$n$$$ has to be even. Otherwise, the tree is impossible and the answer is $$$0$$$.

    Now we are interested to find $$$\sum d(u,v)$$$ over all ordered pairs $$$(u,v)$$$ ($$$u \neq v$$$) for a fixed tree. After rooting the tree you can get a general formula that depends on subtree size of each node and their parities. The formula is easily extended to hold for all trees of size $$$n$$$. (Of course, the final answer has to be divided by $$$n(n-1)$$$ )

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

      What do you mean by a fixed tree?

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

        The tree (a set of currently unweighted edged) is given in the input and the task is to assign weights so it's good. I claim that at most one valid assignment exists.

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

The key idea of problem D is to delete non-zero but not to find zero. After I saw the accepted code I got the idea immediately but it is difficult to change the direction while the round is running. I tried to delete 1 all the time on the round and thought about many ways including random, but it seemed impossible to make the probability small enough to pass the problem. Has anyone passed this problem with a random method?

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

    This method works with very high probability :

    Notice that if you query(x, y) for all y with a fixed x, either p(x) = 0 or p(x) = maximum answer to a query. If you let k be the maximum answer to a query, you can notice that you only need to look at multiples of k, and multiples of k are exactly the elements that answered k to the query. Thus, you divided the number of elements by k doing that. This is almost enough to solve the problem, except if the first element you pick is one, and you're gonna use almost 2n queries before dividing for the first time. To avoid that, you can just ask random pairs until you find an element > 2 and start dividing with this element.

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

      Interesting, this is way easier, but I thought using randomness in the beginning wouldn't work, especially with small permutations, so once I realized the problem of picking 1 as your first number I followed the approach of comparing the first and second elements with each of the next elements until I got a gcd different than 1, since both can't be 1. Then you apply the normal strategy with the remaining elements and since you eliminated one number for every two operations I'm pretty sure this should work, although I haven't been able to get AC yet.

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

      How do you check if, in any iteration,p(x)=0?

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

        if p(x) = 0 then the maximum gcd is the maximum element left so only two elements are leftover and you are finished.

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

          I was saying if my x is such, that p(x) = 0, and elements left in the array are [0,2,4,10] then my answer for queries will be [x,2,4,10=k], from this how to determine whether p(x) is 0 or not?

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

      I tried this approach (just participated virtually now), and it does not work, instead of choosing a random pair I choose a random Y from all multiples of a X, but pretest-5 is evil. :(

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

      I thought about the same method as you described. But in my caculation, valid pairs(gives gcd(a_i,a_j) > 1) only takes about 2/5 in all pairs(C(n,2)) which means we need to do about 20+ times queries to find such a pair with a not-found porbability around 1e-9 and then we need to do at most 2n(n + n/2 + n/4 + ...) times queries in worse case to find the answer. So on the round I thought it is difficult to pass the problem especially for small n like 7 or 8. I cannot give a solid proof of this method but it is true that the real process has a very low probability to enter the worst case(we pick k as 2,4,8,...).

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

I spent about ten minutes to figure out that you should read a 1/-1 after each testcase in problem D.

I bet there's people who spent more TAT.

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

$$$D$$$ looks like author typed something randomly, then suddenly noticed, that this produces "something meaningful", and created problem, which asks to get strictly that "something meaningul".

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

    Well, just to make it clear initial version was to find the whole permutation using atmost $$$3n$$$ queries, which is quite natural and cool imo.

    Testers found it hard and some unintended solution which uses around than $$$3n+\alpha$$$ (where $$$\alpha$$$ varies from $$$30$$$ to $$$40$$$ depending on implementation) were getting cheesed. That is why we decided to have current version. Most of the testers liked it. So we went with current version.

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

My solution to D 185365086 (idea is to take any number and querying it with other valid elements to try to get a higher GCD) shouldn't work but I was able to make it AC through randomization and just running an infinite loop when I am about to exceed total queries so that the system rejudges my submission.

Can anyone try to hack this?

(Edit: Cleaner version 185377734)

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

    Very Clever Solution orz

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

    Errorgorn had warned us about this loophole. That is why we had high number of test cases initially.

    Interaction was taking a lot of time, so we had to reduce the number of test cases.

    Good job btw (:

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

    Wait why the infinite loop does not giving TLE, it's cool hack can you explain lill more about running this infinite loop and system rejudge thing.

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

what's the idea behind B

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

    an easier provable idea: make each element a power of two. The power of two is always found between n and 2n. And it is obvious that if all the numbers are powers of two, then in each pair someone divides the other

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

Mathforces!

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

$$$D$$$ was great. Maintain two possibilies, $$$poss[0]$$$ and $$$poss[1]$$$ as the "possible" indexes where $$$0$$$ can be present. Initially $$$poss[0] = 1$$$, $$$poss[1] = 2$$$. Let $$$ g = gcd(p[poss[0]],p[poss[1]]) $$$. (Use the first query to determine $$$g$$$ initially.

Then, start with index $$$3$$$. (And now we need to update $$$poss[0]$$$ and $$$poss[1]$$$).

Calculate $$$gcd(p[poss[0]],p[3])$$$ and $$$gcd(p[poss[1]],p[3])$$$ and $$$gcd(p[poss[0]],p[poss[1]])$$$ (You have already stored it).

Sort them, lets say sorted values are $$$x$$$ $$$y$$$ and $$$z$$$ where $$$x \le y \le z $$$. It can be shown that if $$$gcd(y,z) = x$$$ and $$$x!=z$$$ and $$$y!=z$$$ then, index $$$p$$$ and $$$q$$$ will be the possible candidates for $$$0$$$ where $$$ p $$$ and $$$ q $$$ are the index among ($$$poss[0], poss[1], p[3])$$$ and no index ($$$p$$$ or $$$q$$$) is common in index corresponding to $$$x$$$ and $$$y$$$. (Index corresponding to, say $$$x$$$ means that the two indexes whose gcd is $$$x$$$.). So update $$$poss[0] = p$$$ and $$$poss[1] = q$$$ if the above conditions are satisfied, otherwise don't update it. Then repeat the process for the next index.

At the end, $$$poss[0]$$$ and $$$poss[1]$$$ are the answers. Link for my submission: https://mirror.codeforces.com/contest/1762/submission/185373278 (Solved it just after contest :( )

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

I don't understand outputs of interactive problem debuging enviroment

https://mirror.codeforces.com/contest/1762/submission/185375790

I manualy checked test1 and test2 and both work hmmm?

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

D has a strong vibe of this problem: https://mirror.codeforces.com/contest/1634/problem/D

Not only it asks to find zero, but solutions are very similar too

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

Why gcd(x,0)=x,is it a definition?

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

I am so sad,my rating will drop,because I have never solved interactive problem,so I always got idleness limite exceed in D,but it is a interesting round.

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

for problem B sort the array and make the i+1th index multiples of previous .

Your code here...

	int n = sc.nextInt();
		
		int arr[] = new int[n];
		int cnt = 0;
		for(int i = 0 ; i < n ; i++)
		{
			arr[i] = sc.nextInt();  
		}
		sort(arr);
		
		int ans[][] = new int[n][2];
		for(int i = 0 ; i < n ; i++)
		{
			ans[i][0] = i+1;
			if(i < n-1)
			{
			if(arr[i+1]%arr[i]!=0)
			{
				ans[i+1][1] =arr[i]- (arr[i+1]%arr[i]);
				arr[i+1] +=  arr[i]-(arr[i+1]%arr[i]);
			
			}
			}
		}
		
		System.out.println(n);
		
		for(int i = 0 ; i < n ; i++)
		{
			System.out.println(ans[i][0]+" "+ans[i][1]);
		}
		

why is it failing anybody

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

    After sorted the indexes are rearranged but you should output the original index

    To fix it you should use pair<int,int> {a[i],i} to store the original index, or let b[i]=a[i]*N+i where N>max(n), then sort b, we can get original index=b[i]%N.

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

On E, I got the AC formula

$$$\sum\limits_{m=1}^{n-1}(-1)^m m^{m-1}(n-m)^{n-m-1}\binom{n-2}{m-1}$$$

but couldn't prove it; can anyone provide some reasoning as to why this works?

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

    How did you figure out the formula during the contest?

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

      I got the observation that, if we root the tree at 1, the label of the edge of each node to its ancestor is $$$(-1)^{\text{subtree size}}$$$. Then, I attempted counting based on $$$n$$$'s subtree, but couldn't really manage the path from 1 to $$$n$$$. Trying to sum over all nodes was a tough task too. I just resorted to guessing after a while, and surprisingly a simple tweak to Cayley's Formula works.

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

    Pick any edge in the path $$$1 \rightarrow n$$$. It divides the tree in two subtrees (let's say that the left subtree contains $$$1$$$, and the right subtree contains $$$n$$$). Then, you can iterate over the size $$$m$$$ of the left subtree.

    • The weight of the edge is $$$(-1)^m$$$.
    • You have to choose $$$m-1$$$ nodes between $$$2$$$ and $$$n-1$$$ to put on the left.
    • You have to choose the shape of the two subtrees.
    • You have to choose the endpoints of the edge.
    • »
      »
      »
      17 месяцев назад, # ^ |
        Проголосовать: нравится +10 Проголосовать: не нравится

      I think you also have to choose the endpoints of the edge. You can do this in $$$m(n-m)$$$ ways and that's why the exponents of $$$m$$$ and $$$n-m$$$ are $$$m-1$$$ and $$$n-m-1$$$ instead of $$$m-2$$$ and $$$n-m-2$$$.

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

Missed being candidate master just for 10 points :'( Thanks for problem D, exactly my favourite type of problem.

Upd: Reached candidate master the next contest!

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

4 th test case in c f([1,3])=1 how, extension of 010 can be 00100,01100,00110 hence f([1,3]) should be equal to 3.

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

    It must satisfy the constraints for all of the previous prefixes too. For example, $$$00100$$$ is not considered an extension as for $$$s_2 = 1$$$, the prefix is $$$b[1, 3] = 001$$$. We can we that the median of this prefix is $$$0$$$, and not $$$1$$$ as it should be.

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

Ratings updated preliminary, it will be recalculated after removing the cheaters.

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

Am I the only one who understood the problem C incorrectly? At first, I thought each prefix is an independent case and later I thought even after surpassing a prefix the elements constructed could be changed with new incoming characters.

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

Can anyone tell me why am I getting Wrong Answer on testcase 2 for my code of problem A:

include<bits/stdc++.h>

using namespace std;

int main() { int t; cin>>t; while(t--) { long long n,i; cin>>n; long long a[n]; for( i=0;i<n;++i) { cin>>a[i]; } long long EvenCount = 0, OddCount = 0, evenmin=9999999,oddmin=9999999,count=0,sum=0,k; long long Even[n], Odd[n];

for(i = 0; i < n; i ++)
{

if(a[i] % 2 == 0) { Even[EvenCount++] = a[i];

}
else
{
    Odd[OddCount++] = a[i];

}
}
 for(i = 0; i < n; i ++)
{
    sum =sum+a[i];
}

for(i = 0; i < EvenCount; i ++)
{
    if(Even[i]<evenmin)
    {
        evenmin=Even[i];
    }
}
 for(i = 0; i < OddCount; i ++)
{
    if(Odd[i]<oddmin)
    {
        oddmin=Odd[i];
    }
}


if(sum % 2 ==0)
{
    cout<<"0"<<endl;
}

else if(sum % 2 ==1)
{

     if(oddmin < evenmin)
     {


      while(oddmin!=0)
      {
          oddmin=floor(oddmin/2);

          count++;

      }
     cout<<count<<endl;
     }
     else if(oddmin > evenmin)
     {


      while(evenmin!=1)
      {
          evenmin=floor(evenmin/2);

          count++;

      }
     cout<<count<<endl;
     }
}






}


return 0;

}

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

    The value of a number is smaller dose not mean it takes less operations to change it parity, like 8(need 3 operations,8->4->2->1) and 10(need only 1 operation,10->5)

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

as not a tester, round was great!

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

MikeMirzayanov i had received a mail regarding plag. Both are my accounts, i gave the contest with both of my id's simultaneously.

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

ez div2!

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

Hi, the Editorial to Problem C is wrong.

For eg: consider -> 110111 according to Editorial for f([1,6]) = 2^2 , which is wrong.

There are 2^3 possible ways for f([1,6]).

Proof: 1 _ 1 _ 0 _ 1 _ 1 _ 1 Possible values: 2 1 1 2 2 => 2*1*1*2*2 = 2^3

The answer should not be 2^(max continous len — 1).

Rather, it should be like this

For every consecutive same elements, we can fill gaps with 2 options (0,1), and if there are different elements then we can only fill with only 1 option.