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

Автор Bazoka13, история, 3 года назад, По-английски

Hi Codeforces!

We are glad to invite you to our first Codeforces Round Codeforces Round 738 (Div. 2) which will be held on Aug/15/2021 17:35 (Moscow time). This round will be rated for participants with rating less than 2100. We will be glad to see participants from the first division to join out of competition as well!

In this round, as the best friend of Mocha's, you are going to help her to solve the problems she meets.

The problems are prepared by 2sozx, JJLeo, Serval, Oshwiciqwqq and me. We hope you will enjoy the round. :P

We would like to thank:

You will be given 5 problems to solve in 2 hours.

Scoring distribution: 500—750—1000—(1500—1500)—3000.

We recommend you to read the statements of all problems. Good luck & Have fun! :D

UPD: Great thanks to KAN and isaf27 for helping with Russian language translation and clarifications.

UPD2: Sorry for the long queue and my mistake in estimating the difficulty of problem D2 and E.

UPD3: Editorial is available now.

UPD4: Thank you for your participation in this round! Congratulations to the winners!

Div. 2

  1. Suckmycode
  2. Wlxsohandsome
  3. idontwannawin
  4. shu_ya_zi
  5. _Kubic_

Div. 1 + Div. 2

  1. neal
  2. ksun48
  3. Geothermal
  4. sjc061031
  5. Kirill22
  • Проголосовать: нравится
  • +796
  • Проголосовать: не нравится

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

Darn, my VIP tester streak ended.

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

Announcement blog 3 days before round -> bad round

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

As a tester, have fun!

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

As a tester. You must be careful with your code and try to solve $$$x$$$ ($$$1 \leq x \leq 5$$$) problems!

Good luck!

-QuangBuiYT

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

Hoping to regain specialist after this round!

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

As a tester, oooops I find myself a problem setter! lol

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

As a coauther & tester for the first time, I hope you enjoy this round!

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

orz

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

As a tester, hope you enjoy those excellent problems and wish you all high rating!

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

Hope to become pupil again this time!

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

The scoring distribution looks noice!!!

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

hoping for nice round and thanks author for spending your time for us

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

Hope for a great round,and thanks for the early score distribution!

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

OrzOrz

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

As a tester,I'm sure that it is a fabulous round!

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

As a Participant, I Would like to remind my Fellow Participants, not to get wooed by the Easy Score Distribution, as the Problems are gonna be hell a lot Tricky & many of us will be getting...

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

speedforces ABC?

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

    Maybe not speedforces, but balanced like 1300 A, 1500 B, 1700 C or something like that but harder than normal round ABCs.

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

why he write 6problems as e is the hard version of d only

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

Behold The Chinese Round! Orz

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

Good luck to everyone!

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

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

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

    If we are given 5 problems so why the scoring distribution is saying we're ganna have 6 problems ?

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

      1500 appeared twice inside the bracket denotes easy version and hard version of the same problem, and the only difference between them is the data constraints.

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

As a participant,Orz yourself

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

I have a mock round for my ICPC regionals and it ends just 5 minutes before the start of this codeforces round. Challenge accepted.

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

As a tester up vote me ,problems are very nice

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

As a tester, hope you enjoy those excellent problems and wish you all high rating!

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

Glad to see partial Scoring :)

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

i hope i can get top 10 in this contest

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

Hope I can become Candidate Master again.

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

    Wow, this round was prepared by students from Beihang, which my ideal university is!

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

Won't be able to attend this round for some personal reason. Wish all the participants good luck. Hopefully, you will have a great time brainstorming.

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

i wanna be specialist again, wish me good luck qwq

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

pls not bitwise again

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

I hope PUPIL this time

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

Have they forgot to send an email? I didn't receive any!

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

Hoping for Pupil :)

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

I have searched the whole post for these few words "The statements will be short and clean." But unfortunately, I couldn't find it and get disappointed :[ :P .

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

Ok. I'm ready to help my new friend Mocha, if can :D

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

The downside of giving an easy A is you get a long queue...

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

queue not ending!

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

queue forces

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

Queue is taking too long,if we get a wrong ans it tells us after minutes,and because of that we can't focus on ongoing quuestion, and time is also lost

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

queueforces ???

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

Speedforces + long queue = RIP ratings:(

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

I think so many cheaters around there , solution are leaked in telegram, youtube

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

    Dude, Why are u searching that in contest time. xD

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

      Dude cheating doesn't make sense , I suspected submissios for B and C

      Especially B , See how less submission difference for A and B

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

        Oke. but u should use your brain more without wasting time in thinking about cheating at least in contest time. (:
        I also against cheating may be most of them ^_^

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

I want to see that shittiest pretest 2 for B

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

Hope I can become Candidate Master.

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

div2.5

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

one of the most standard rounds I have seen in my life

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

Hope to becume ♂Dungeon master♂ after this round

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

is the solution to D2 some form of optimization of D1 using bitset in C++?

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

    I'm not sure what was intended, but I used a randomized approach until there existed a connected component of large size, then I just tried all edges that have an endpoint not in that large component.

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

Nice problems!

Here's an extended version of $$$C$$$ which is cool:

You won't be given the array $$$a_i$$$ itself, instead you will be given $$$n$$$ and you can interact and ask for particular values of $$$a_i$$$. Ask at most $$$20$$$ queries and output the answer as required in the original problem. Assume $$$n < 10^5$$$.

Okay here is a solution as some people are asking:

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

    How would this version be solved?

    I have thought of a way in which we can find if the first element is 1 (to check for chains like n+1,1,2,3,4,...n) and to ask if a[n]==0 to check for chains like 1,2,3,4,5,...n,n+1.

    However how to check for other cases where the answer is possible.

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

      you have to find place i where a[i] == 0 and a[i + 1] == 1.

      you can do that using binary search.

      after you find it (or if it doesn't even exist) you can solve it

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

        How to find it using binary search?

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

          tbh I'm not sure whether this works but I would do sth like that

          if a[beg] == 0 and a[end] == 1 {
            if a[mid] == 1 then search in a[beg]..a[mid]
          
            else if a[mid] == 0 then search in a[mid]..a[end]
          }
          

          I hope this works :D

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

        But the number of queries will be greater than 20 ( log(10^5)==18 and then in each step of binary search we have to ask two values so 2*18==36>20 )

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

    Yea, nice one.

    But I personally don't like it when problem consists of 10 easy subproblems, so I would make this as a standalone problem

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

    What type of queries we can ask from interactor?

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

    It exists on cf https://codeforces.com/problemset/problem/1019/B . It is one of my fav problem.

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

How to solve E?

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

    E was just like you calculate total number of sequence or pairs with gcd == x, like go from end

    pseudo code be like
    for j = m to j = 1:
    ans[j] = calculate(j)
    for(int i = 2 * j ; i <= m; i+=j) ans[j] -= ans[i]

    calculate(j) is of complexity m / j * n, using dynamic programming
    in total its $$$\sum_{y=0}^{m} (n * (m / j)) = O(m n log m)$$$

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

    let f(i) = number of sequence of length n with gcd == i for each range [lj,rj] 1 <= j <= n , there will [ (lj+i-1)/i , rj/i] number of element which are of multiple of i and therefore number of choices as well.

    Now, to compute f(i) we need to find a solution to the equation

    a1 + a2 ... an = m/i where each aj : [(lj+i-1)/i,rj/i] we can use PIE to solve above equation.

    Now, total number of sequence with gcd 1 will be sum of mu(i)*f(i) over 1 <= i <= m

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

Even though I am not the target participant for this problemset, I thought the authors might enjoy some feedback.

  • A: No comment.

  • B: Classic problem. It is ok to give a classic problem as easy problem.

  • C: The construction is clean, I liked it. The difficulty is appropriate. It is very similar to the construction of an Hamiltonian cycle in a tournament.

  • D: Very cool problem. One immediately guesses that it must be possible to add an edge until one of the two forests becomes a tree. Then, it is easy to obtain an $$$O(n^2)$$$ solution, which is enough for the easy subtask. The hard subtask, which was quite hard for me, requires to optimize the solution to something pseudo-linear (in my case to $$$O(n \log(n)^2)$$$, but I am pretty sure that it is possible to do better). I really enjoy problems about optimizing quadratic solutions to pseudo-linear, and this is a great example of such a problem. It was a very nice idea to split the problem in two subtasks since the easy version is considerably easier than the hard version but still interesting.

  • E: Standard problem. If one knows the right techniques (i.e., mobius mu function and backpack with copies of the same item) this is straightforward.

Overall, it was a well-prepared contest. I had fun thinking about problem D. Thanks to the authors.

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

    can you share some resources to learn the topics u mentioned for problem e ?

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

    In problem D, you can add all possible edges from $$$1$$$ to other vertices. Then, divide all vertices into two groups: the first group consists of vertices in the same CC with $$$1$$$ in the first graph and in different CC with $$$1$$$ in the second graph, the second group is vice versa (some vertices may not lie in any group). Now we can add an edge between any pair of vertices from different groups, so we just have to maintain two queues of these groups and delete a vertex from a queue if it becomes bad at some point. Overall, it works in $$$O(n \cdot DSU(n))$$$.

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

      Neat solution. I would have never found this one during the contest.

      My solution is more involved (and thus I will not describe it). It maintains a sufficient amount of helping structures so that it is always possible to find a good edge to add in $$$O(\log(n))$$$ amortized time per edge (and $$$O(\log(n)^2)$$$ amortized time is required to update all the structures when an edge is added).

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

    Interesting, that the mu function makes it straightforward. But since I have no about what it is (:P), I ended up with a separate DP which counts arrangements for all GCDs efficiently, eventually ending up with GCD = 1 arrangements.

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

      The important formula is (valid for any set $$$S$$$ of $$$n$$$-uples)

      $$$ |\{(a_1,\dots,a_n)\in S:\ \gcd(a_1,\dots,a_n)=1\}| = \sum_{d=1}^\infty \mu(d)|\{(a_1,\dots,a_n)\in S:\ d|a_1,\, \dots,\,d|a_n\}| \,. $$$

      It is not hard to prove (once you look up the properties of the Mobius function $$$\mu$$$ on wikipedia) and it comes handy in a large number of problems.

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

        Can you share some resources from where a beginner (in this topic) can practice them?

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

        Very cool, thanks a lot! I'm probably going to spend tonight learning more about it :)

        As for the DP solution I mentioned, the idea is to iterate over all values $$$g <= M/N$$$ in decreasing order, calculating the number of arrangements that follow the constraints on the sum and the individual value ranges, such that the GCD of the sequence is $$$k*g$$$ for some positive integer $$$k$$$. $$$dp[i][j]$$$ = number of valid suffixes starting at $$$i$$$ and with sum at max $$$j*g$$$ that follow the constraints I mentioned above. To transition, take the sum of all $$$dp[i][j-x]$$$ such that $$$l[i]/g <= x <= r[i]/g$$$. We can make transitions constant time by maintaining prefix sums.

        Now, let's denote arrangements with GCD exactly $$$g$$$ as $$$count[g]$$$. $$$count[g] = dp[0][M/g] - \sum count[x]$$$, where $$$x$$$ are multiples of $$$g$$$. Our answer will lie in $$$count[1]$$$.

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

    Edit: I am talking about D2

    I also had the $$$(\log{n})^2$$$ idea initially (small to large merging with some multiset-like data structure). I optimized it by using the following simple idea to construct edges:

    If any forest becomes connected, we are done. Otherwise, both forests have at least $$$2$$$ components. Consider any two nodes $$$x$$$, $$$y$$$ in distinct components of the first forest and any two nodes $$$p$$$, $$$q$$$ in distinct components of the second forest.

    If $$$x$$$ and $$$y$$$ are in distinct components of the second forest, then add edge between $$$x$$$ and $$$y$$$. Otherwise, at least one among $$$u$$$ and $$$v$$$ will be in a different component than $$$x$$$ and $$$y$$$ in the second forest, say $$$u$$$. Now, at least one among $$$x$$$ and $$$y$$$ will be in different component than $$$u$$$ in the first forest, say $$$x$$$. So merge $$$u$$$ and $$$x$$$.

    This construction in fact acts as a proof for the solution!

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

Solved A and C but with 9 wrong answers and very slow. My worst contest yet. Look forward to improving speed and accuracy.

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

Thanks for the contest, it had nice problems especially C and E.

However I'm not much of a fan of D1. I saw constraints and just guessed that trying every edge in any order would work. I suspect that many other participants did the same without even trying to prove it.

Just my opinion, but I'm not much of a fan of problems where guessing the answer and getting proof by AC is significantly easier than proving why it works.

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

    I think it was not guessing the answer.

    If you have read/studied Krushkal algorithm it uses Dsu to ensure that the new vertices do not form cycle with previous edges. Same is the case with this problem.

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

    I took all the unaccounted edges in a set and traversed through all and checked whether adding would lead to a cycle in any of the 2 graphs. However, I got time limit exceeded on test 6. Can you tell what extra optimization did you do? Here's my submission.

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

      Going through all the unvisited edges is alredy n^2, checking for cycle makes it n^3 but i'm not sure if it's mathematically n^3 only or not. Rather, just check if it's part of different trees or not by mantaining array marking some sort of tree number for every node and mantain this array. Again, not exactly sure what the complexity will look like for this.

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

    My explanation is that:

    $$$[1]$$$ Let $$$u$$$ and $$$u'$$$ are any 2 nodes in Mocha graph that not in the same connected component

    $$$[2]$$$ Let $$$v$$$ and $$$v'$$$ are any 2 nodes in Diana graph that not in the same connected component

    There will be at least a way to connect $$$u-v, u-v', u'-v, u'-v'$$$ to form 2 forests without making a cycle to it.

    If there is no such $$$u'$$$ or $$$v'$$$ then there will be no more edge since no matter how we add edge it will form a cycle else we can repeat this multiple times

    No matter what is the order you choose for the edges to be add, it will always such edges that satisfy the statement — which is not making a new cycle into graph — such $$$u-v$$$ or $$$u-v'$$$ or $$$u'-v$$$ or $$$u'-v'$$$ satisfied $$$[1], [2]$$$

    Therefor we will have the result of maximum possible edges can be added, by keep finding new $$$u, u', v, v'$$$ satisfied $$$[1], [2]$$$

    By using brute-forces algorithm for each possible $$$i$$$ and $$$j$$$, we tested for all for cases ($$$i = u$$$ or $$$i = u'$$$) with ($$$j = v$$$ or $$$j = v'$$$) for any $$$u, u', v, v'$$$ satisfied, those who are not will not included in the result, those of which are needed will added to result

    We don't need to redo the brute-forces every times we add a new edges, since those are which either already an edge or will make a new cycle, and will never satisfy again

    Using Disjoint Set Union Data Structure, we can check for any 2 nodes that in the same connected component or not

    Therefore we only need brute-forces for $$$O(n^2)$$$ with a little help of data structure $$$O(\alpha(n))$$$ amortized per query

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

    Well some proofs for D1 did help in solving D2. For example my proof (and solution for D2) described here.

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

Nice contest, kudos to the authors.

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

Problems were really nice. I would have expected a harder E and an easier D2 but it was good however. Congrats to the problemsetters.

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

Can someone please tell me when there will be -1 solution for problem C. And also Solution for C.

As per my intuition there will always be a answer.

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

Did anyone solve E using Polynomial Multiplication and FFT ? I tried to implement it but it gave incorrect output for Sample Test Case 3 and then I could'nt debug it

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

Not good for div 2 contest

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

WOW!! Score distribution was correct!! :p

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

Does anyone have code for generating random forests so I can test my solution for D1 before the System Test ends?

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

can someone tell me how to do A XD?

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

    u just use the & operation over all the elements...

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

      bruh

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

        It is simple problem hidden behind complecated words.

        Since we can pair any element with any other element, we can remove any bit that is not set in all numbers. One simple way to find that bits is doing AND on all numbers.

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

    ans=a1&a2&a3&a4&...&an, since a&b is always not greater than a and b themselves.

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

    I just apply operation on the whole array until i get an array with all element being equal.

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

D2 O(n * dsu(n)) solution from ♂Dungeon master♂

Maintain two dsu, one for each forest. Ass long ass there is a vertex that is not connected to vertex 1 in first graph and vertex 1 in second graph, connect it with vertex 1 in both forests. Then ass long ass there is a vertex X in first graph that is not connected to 1 and vertex Y in second graph that is not connected to 1, connect X and Y in both forests. Can be performed with two pointers, one find X, other find Y. Proof is on you, ♂slaves♂

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

I'm surprised 5k people solved D1

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

    Well, DSU is quite a common data structure nowadays most of the newbies and pupils know about them if they have gone through the kruskal's algorithm.

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

      I expected the sulution to need some clever ordering of connecting the components. I still do not see how any order can allways be optimal.

      So the problem is not to know DSU, it is to see (or just try) that brute force works.

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

D2 is truly interesting...Thanks for such problems

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

has anyone solved C using reverse edges and starting dfs from node n + 1? i just want to know if its a correct solution

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

Also, was there a reason for $$$n \leq 10^4$$$ in problem C? Both the solution and the judge seem trivial to code in $$$O(n)$$$. Was the problem initially interactive somehow?

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

I will FST on C, I believe there was no pretest with all 1's... Why?

Edit: I failed indeed. Overall I enjoyed the contest. I think having some pretest with all 1's was needed. I was surprised because even if it is a useful test or not, it seems like if the input is an array where the values can only be 1 or 0, arrays with all 1's or all 0's naturally come to mind as tests. That's what I think, though I'm not a problemsetter. I hope someone finds this feedback useful. As I said, I really enjoyed the round anyway.

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

arcaea www

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

can we find number of solution of a1 +a2 +a3 ... an = m with upper bound on each variable in O(n) or O(n^2)

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

    I imagine using Multinomial Theorem and Polynomial multiplication we can do that in $$$O(N*MlogM)$$$.

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

    I think I used the approach you are describing for problem E. I just could not think of anything so I came up with a kind of naive $$$O(nmlog^2(m))$$$ solution where we iterate through values from m to 1 and we calculate $$$f(i)$$$ which is the number of solutions that satisfies the first and second condition, and the gcd of all n numbers are a multiple of i. Then if we can efficiently find f(i), we can calculate $$$g(i)$$$ which is the number of combinations that satisfies the first and second condition, AND the gcd of all n numbers are exactly i, via the relationship $$$g(i) = f(i) - \sum_{j=2}^{m/i} g(i*j)$$$ which can be calculated in $$$O(mlog(m))$$$ due to the harmonic series. For calculating $$$f(i)$$$, you can use a knapsack dp that runs in $$$O(nmlog(m)/i)$$$ for each i using BIT. Then we obtain a solution $$$O(nmlog^2(m))$$$.

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

    I think I solved it in $$$O(nm)$$$ using the formula given by inclusion-exclusion principle, as presented in this Stackexchange link.

    Firstly, you precompute factorials to be able to compute binomial coeficient fast.

    Secondly, you compute how many even-sized and odd-sized subsets give a certain sum $$$x$$$. We compute sets of different parity separatelly, to quickly compute $$$(-1)^{|S|}$$$. This is done by knapsack-like loop (remebember to increase upper bounds by one before running the loop):

    for each upper bound r:
        for each possible sum x in m downto r:
            odds[x] += evens[x - r];
            evens[x] += odds[x - r];
    

    Thirdly, now we know the number of subsets that have given sum of $$$r_i$$$, so we iterate over those sums and change our ans accordingly: ans += (evens[x] - odds[x]) * binomial(n + m - x, n) (+-1 ommited for clarity).

    If you want to compute number of solutions to $$$a_1 + a_2 + ... + a_n \leq m'$$$ then it corresponds to $$$m$$$ going from $$$0$$$ to $$$m'$$$ in the formula from third step. Notice, that most of those binomial will be equal to $$$0$$$ if we process them in the reversed order (aka from $$$m'$$$ to $$$0$$$).

    We introduce variable $$$help = 0$$$ and simply increment it by $$$binom(m' - x + n, n)$$$ and change our ans accordingly: ans += help * binomial(n + m - x, n).

    Unfortunatelly, I finished coding just after the round and now I'm impatiently waiting for system tests to finish and submit possiblity. #feelsbadman

    Edit: It passed systests: Submission 126025440 :D

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

      replying to find it later.

      p.s -> how to find a particular comment easily later ?

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

        There are those permalinks to comments (# symbol in the comment header, like https://codeforces.com/blog/entry/93788?#comment-829093). I guess you could save those in some file comments you find interesting.

        I, for one, have never needed to save a particular comment. With blogs / articles I intend to read later, in Chrome there is a list to read. You press the favourite star symbol in the address bar and the option pops out.

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

          I figure the api design. But how will I know the ID is of your comment lol.

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

      we could also use generating function to calculate the formula like this
      basically we need to calculate

      $$$[x^m] \prod_{i} \sum_{j = l_i}^{r_i}x^j$$$
      $$$[x^m]\left( x^{\sum_{}l_i} \right) \times (1-x)^{-n} \times \left( \prod_{i}(1 - x^{r_i - l_i + 1}) \right) $$$
      $$$[x^{m-\sum_{}l_i}] \times (1-x)^{-n} \times \left( \prod_{i}(1 - x^{r_i - l_i + 1}) \right) $$$

      we can calculate coefficients of this polynomial $$$\prod_{i}(1 - x^{r_i - l_i + 1}) $$$
      in total of $$$O(n * m)$$$ time using knapsack dp as we need atmost m powers.

      as we need sum of all coefficient we need to multiply the equation by $$$(1-x)^{-1}$$$ again
      so finally we need

      $$$[x^{m-\sum_{}l_i}] ( (1-x)^{-(n+1)}) \times \left( \prod_{i}(1 - x^{r_i - l_i + 1}) \right) $$$

      As power is fixed this becomes $$$O(m)$$$ to calculate, as negative binomial expansion coefficient for any power of $$$x$$$ can be represented in closed form

      after using harmonic sum property for all calculating gcd = 1 total complexity becomes
      $$$\sum_{i=1}^{m} calculate(x / i)$$$ = $$$ O(m.n.log(m))$$$

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

https://codeforces.com/contest/1559/submission/125941230 — sent at minute 8, evaluated at minute 10 https://codeforces.com/contest/1559/submission/125944849 — sent at minute 13, evaluated at minute 17 https://codeforces.com/contest/1559/submission/125939758 -> https://codeforces.com/contest/1559/submission/125946723 !! — sent at minute 6, evaluated at minute 8

my submission: https://codeforces.com/contest/1559/submission/125937327 — sent at minute 4, evaluated at minute 20.

This weird late evaluation gave others a faster time to resubmit and eventually get accepted (and they did), but my submission was evaluated very late (although submitted very early!), and that gave me a great disadvantage).

Could anyone explain how this could've happened?

MikeMirzayanov sorry to tag you, but I don't want to lose rating over this. If my solution would've been evaluated instantly, it would've still taken me a minute to correct the problem, and now I am facing a 15 minute penalty (which normally should be 3, and now costs me a lot of rating) for very ambiguos reasons :(

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

    I too had a queue of over 15 minutes for my C. Never seen a contest with this long queue ever being rated. I even had gotten up then thinking the contest would definitely get unrated. I don't mind having long queues for rated contests, just some standard should be followed. On one day a 15 minute queue makes unrated, on some other day it doesn't. RIP Ratings. I got quite nervous.

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

Thanks for the great round! :) I like problem D2 very much, it's the most interesting problem I've ever seen :)

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

Почему есть задачи про мочу, но нет задач про ♂cum♂?

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

Can't I solve E with FFT or NTT?

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

Now that's a contest (UPD: WOW FST on test 57)

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

In C. Mocha and Hiking, can't we just go from 1st village to final village through every village continuously? I mean, 1 2 3 4 ... n+1 Isn't this a solution? I know that if this is a stupid answer, but technically, it is satisfying the conditions, right?

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

Nice round. loved it.

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

what's this??? My solution for A and C was accepted and pretest(3) and pretest(15) passed for A and C respectively. But after system testing both become WA. If WA shows in the live contest then maybe I solve it with different approach.

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

After solving A-D1, I got nothing to do.

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

Nice problems guys. Good team work!

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

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

    lol. But it was easy. I just guessed the answer without even understanding why it works.

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

It's a good contest.

But I have a question:

Could anyone hack my code(D2): https://codeforces.ml/contest/1559/submission/126013197

Maybe it's easy to hack...

upd:hacked by peti1234

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

i bricked this contest can i hvae some contrubtion points

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

It's a nice contest in general.But I should say that the difficulty between ABCD1 and D2E is like a cliff

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

ranran(Diana) you take me away!

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

Problem D1: This is the easy version of the problem. The only difference between the two versions is the constraint on n.

I have an AC code on problem D2 and the same code got WA on D1 ?!!

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

editorial?

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

To not keep you waiting, the ratings are updated preliminarily. In a few hours/days, I will remove cheaters and update the ratings again!

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

    Hi. Can you tell me why my rating decreased even after solving 2 questions of div 2 contest when I am in div 3. My rating decreased from 1078 -> 1060.

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

      It doesn't matter how many problems you solved, what matters is how good you did compared with others and your current rating. You solved less problems or solved them slower than people with similar rating, therefore your rating went down.

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

        So should I not give contests which are rated for div 1 & 2 for now? I am in div 3 right now and am still learning about competitive programming.

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

          You should still give contests rated for Div. 2 and everyone, it's a great opportunity to practice your competitive programming skills.

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

Succeed!I am not a newbie now.

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

Great Round, thanks!

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

Thanks for the great contest. But unfortunately I got negative delta again :(

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

Received a mail saying my solution to B coincides with this, and I agree, it does. But I think it's a reasonable solution. Surprised there was only one such clash. Obviously don't have any evidence to "prove" that I didn't copy. Any ideas as to how I can refute this?

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

    I think it's reasonable that two submissions is almost the same in a div2.B.

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

Внимание!

Ваше решение 125935124 по задаче 1559A значительным образом совпадает с решениями других участников и находится в группе одинаковых решений kefaa2/125934878, RoadToExpert666/125935124.

Я не списывал, совпадение — чистая случайность(но я горд что пишу код как LGM). MikeMirzayanov

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

MikeMirzayanov I've got a message that the following solutions coincide: SunTakesTooLongToDie/125962649, Tony1234_/125963558

The code is obviously taken from this blog

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

MikeMirzayanov, I've received a system message saying :"Your solution 125949787 for the problem 1559C significantly coincides with solutions spy20051623/125949787, ZeldaHuang/125971185."

The code is completely written by myself and I didn't send it to anyone during contest time. The problem is not difficult for Experts and Candidate Masters to solve, and it's possible to write similar codes.

In addition, I find many solutions similar to it, such as 125971285, 125972457 (I chose them just from common standing page 3).

I hope my "violation" to be checked again.

Thank you all staffs!

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

In the official standings how did rank 296 got 100+ delta while CMs above him with lower rating got lesser delta