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

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

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
  • Проголосовать: не нравится

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

Darn, my VIP tester streak ended.

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

Announcement blog 3 days before round -> bad round

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

As a tester, have fun!

»
5 лет назад, скрыть # |
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

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

Hoping to regain specialist after this round!

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

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

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

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

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

orz

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

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

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

Hope to become pupil again this time!

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

The scoring distribution looks noice!!!

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

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

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

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

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

OrzOrz

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

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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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 ?
»
5 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

speedforces ABC?

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

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

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

Behold The Chinese Round! Orz

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

Good luck to everyone!

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

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

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

As a participant,Orz yourself

»
5 лет назад, скрыть # |
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.

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

As a tester up vote me ,problems are very nice

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

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

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

Glad to see partial Scoring :)

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

i hope i can get top 10 in this contest

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

Hope I can become Candidate Master again.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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.

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

i wanna be specialist again, wish me good luck qwq

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

pls not bitwise again

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

I always wanted such an amazing score distribution lol.

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

I hope PUPIL this time

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

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

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

Hoping for Pupil :)

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -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 .

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

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

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

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

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

queue not ending!

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

queue forces

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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

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

queueforces ???

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

Speedforces + long queue = RIP ratings:(

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

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

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

I want to see that shittiest pretest 2 for B

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

Hope I can become Candidate Master.

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

div2.5

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

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

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

Hope to becume ♂Dungeon master♂ after this round

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

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

»
5 лет назад, скрыть # |
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 \lt 10^5$$$.

Okay here is a solution as some people are asking:

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

How to solve E?

»
5 лет назад, скрыть # |
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.

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

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

  • »
    »
    5 лет назад, скрыть # ^ |
    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))$$$.

    • »
      »
      »
      5 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +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).

  • »
    »
    5 лет назад, скрыть # ^ |
    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.

    • »
      »
      »
      5 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +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.

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

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

      • »
        »
        »
        »
        5 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +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 \lt = 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 \lt = x \lt = 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]$$$.

  • »
    »
    5 лет назад, скрыть # ^ |
    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!

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

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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится -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.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 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.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 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

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

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

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

Nice contest, kudos to the authors.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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

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

Not good for div 2 contest

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

WOW!! Score distribution was correct!! :p

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

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

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

can someone tell me how to do A XD?

»
5 лет назад, скрыть # |
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♂

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

I'm surprised 5k people solved D1

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

D2 is truly interesting...Thanks for such problems

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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?

»
5 лет назад, скрыть # |
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.

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

arcaea www

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 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)

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

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

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 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))$$$.

  • »
    »
    5 лет назад, скрыть # ^ |
    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

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

      replying to find it later.

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

    • »
      »
      »
      5 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 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))$$$

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

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

my submission: https://mirror.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 :(

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +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.

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

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

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

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

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

Can't I solve E with FFT or NTT?

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

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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 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?

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

Nice round. loved it.

»
5 лет назад, скрыть # |
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.

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

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

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

Nice problems guys. Good team work!

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

»
5 лет назад, скрыть # |
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

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

i bricked this contest can i hvae some contrubtion points

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

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

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

When will rating be updated?

UPD: Ratings changed Thanks.

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

ranran(Diana) you take me away!

»
5 лет назад, скрыть # |
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 ?!!

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

editorial?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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!

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

Succeed!I am not a newbie now.

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

Great Round, thanks!

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

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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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?

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

Внимание!

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

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

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

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

The code is obviously taken from this blog

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 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!

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

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