Please read the new rule regarding the restriction on the use of AI tools. ×

By awoo, history, 5 years ago, translation, In English

Hello Codeforces!

On Jan/14/2020 17:35 (Moscow time) Educational Codeforces Round 80 (Rated for Div. 2) will start.

Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.

This round will be rated for the participants with rating lower than 2100. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 6 problems and 2 hours to solve them.

The problems were invented and prepared by Roman Roms Glazov, Adilbek adedalic Dalabaev, Vladimir vovuh Petrov, Ivan BledDest Androsov, Maksim Neon Mescheryakov and me. Also huge thanks to Mike MikeMirzayanov Mirzayanov for great systems Polygon and Codeforces.

Good luck to all the participants!

Our friends at Harbour.Space also have a message for you:

Hello Muscat

Hi Codeforces!

As a special prize for the Educational Round 80, we would like to invite the top 3 participants to take part in our Hello Muscat ICPC Programming Bootcamp, which will take place in Oman, from March 19 to March 25, 2020. The prize will cover the participation fee, accommodation, and half-board meals for the entire duration of the bootcamp (except flights)!

There are three requirements to satisfy:

  • You took part in at least 10 rated contests on Codeforces
  • Your max rating should be less than 2400
  • You should be eligible for ICPC and/or IOI 2020+
Fill out the form→

Good luck to everyone!

Note: If you really want to participate, but cannot afford the participation fee, get in touch with us to request a supporting letter for you to show to your university, employer, or local companies. With this letter, you are opening the possibility of being sponsored by them to attend the bootcamp.

Please fill out this form and we’ll send you the support letter within 3 days!

Congratulations to the winners:

Rank Competitor Problems Solved Penalty
1 isaf27 6 150
2 FSTForces 6 167
3 jiangly 6 178
4 ko_osaga 6 179
5 jhnan917 6 184

Congratulations to the best hackers:

Rank Competitor Hack Count
1 surung9898 59:-2
2 stdmultiset 35:-1
3 B2ej5SjC 30
4 spectre_1502 21:-1
5 Dilemma27 20:-4
434 successful hacks and 746 unsuccessful hacks were made in total!

And finally people who were the first to solve each problem:

Problem Competitor Penalty
A okwedook 0:01
B neal 0:04
C ko_osaga 0:06
D RUSH_D_CAT 0:07
E peach 0:17
F jiangly 1:13

UPD: The editorial is out

  • Vote: I like it
  • +210
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it +57 Vote: I do not like it

Your max rating should be less than 2400 I hope it's not a typo.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +53 Vote: I do not like it

    Hi aryanc403! It is not a typo :)

    The prize is for users who have never been "red". Good luck in the contest!

»
5 years ago, # |
  Vote: I like it +9 Vote: I do not like it

I wonder why Div1 people are not listed as unofficial participants (with a * ) for educational rounds. Is it intentional?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +12 Vote: I do not like it

    I think they don't have the star because they can hack official participants in hacking phase. In regular div 2 rounds the rooms for official and unofficial participants are separated.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +25 Vote: I do not like it

      The hacking phase is only after the round. Div3 contests work in the same way but unofficial participants get a star.

      The first educational rounds were not rated so everyone was an official participant. The educational 33 was first rated one. They just didn't change how the scoreboard is shown.

»
5 years ago, # |
  Vote: I like it +24 Vote: I do not like it

Waiting for good problems to learn new concepts.

»
5 years ago, # |
  Vote: I like it +21 Vote: I do not like it

hope contest gap will decrease

»
5 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Seems it will be a high-quality contest

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

contests by awoo are always fun.

»
5 years ago, # |
  Vote: I like it +58 Vote: I do not like it

Why always Educational's blog had a few upvotes :( These Rounds are really educational, interesting and helpful . They are underrated i thnik .

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

MikeMirzayanov it seems the https certificate of pubsub.codeforces.com is expired and my internet security is constantly blocking the connection to the same, saying it is insecure. Did the certificate expire recently?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Every second which i spent with codeforce gives me an infinite pleasure.

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

"The statement is not available" — m2.codeforces.com

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve C?

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it +17 Vote: I do not like it

    Suppose we take two arrays a,b such that the ascending array ends with number i, and descending array ends with number j. If we count all ascending arrays ending in i and descending arrays ending in j, then we have the answer for this specific i,j.
    Once we can do that, we can simply iterate over all i,j (with $$$i <= j$$$) and get the total answer by summing these values.

    So the question is, given an ascending array ending in the number i, with length m, how many such arrays can there be? We can see that such an array can be like 11122233...i, or can be 1222333444...i, or iiiiiiii...i. So let $$$a_1$$$ be the number of elements that are 1, $$$a_2$$$ be the number of elements that are 2, and so on till $$$a_i$$$. Then the answer is equivalent to the number of integer solutions to $$$a_1 + a_2 + a_3 ... a_i = m$$$, where $$$a_i >= 1$$$ and the rest are $$$geq 0$$$. The answer to this is through stars and bars $$$C(i + m - 2, m- 1)$$$. Similiarly you can do for j (you need numbers from j to n), and you will get something like $$$C(n - j + m - 1, m - 1)$$$. and then multiply and sum to calculate the answer.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Can you explain with more details?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        68799118

        Exactly what is the confusion? The formula, or the approach?

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          approach

          • »
            »
            »
            »
            »
            »
            5 years ago, # ^ |
              Vote: I like it +1 Vote: I do not like it

            The last element of the ascending array must be smaller than or equal to the last element of the descending array. I iterated over all unique (last ascending, last descending pairs), and for each such pair, calculated the answer if the last element of each array was as given.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Could you explain to me the formula for stars and bars?

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanks

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Amazing explanation ! The critical observation here is that the last element of $$$A$$$ is smaller than the first element of $$$B$$$

      $$$A_1 \le A_2 \le ... A_m \le B_m \le B_{m - 1} \le ... \le B_1$$$

      And then you explained how to count the number of non-increasing and non-decreasing sequences of length $$$m$$$.

      Beautiful !

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The no of integer solutions of a1+a2+a3+...+ai=m is given C(m+(i-1),m) but why did you write C(i+m−2,m−1)? I think you took m=m-1, but why?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Because $$$ a_i >= 1$$$, as the sequence ends in i. Therefore we can make $$$a_i >= 0$$$ and take m = m — 1.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +51 Vote: I do not like it

    The answer can be proven to be

    $$$\binom{n+2m-1}{2m}$$$
    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +4 Vote: I do not like it

      Can you give the proof?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +50 Vote: I do not like it

        So say the numbers are $$$1\leq a_{1} \leq a_{2} \leq .... \leq a_{m} \leq b_{m} \leq b_{m-1} \leq .... \leq b_{1} \leq n$$$.So basically we have to select $$$2m$$$ numbers from $$$[n]$$$ which may not be necessarily distinct.Let the numbers be $$$1\leq c_1 \leq c_2 \leq ..... \leq c_{2m}\leq n$$$(I have taken the notation $$$c_i$$$ just for convinience).Now consider the sequence $$$d_i=c_i+i$$$.Clearly there is a bijection between $$$c \Longleftrightarrow d$$$.But note that $$$2\leq d_1 < d_2 < ... d_{2m}\leq n+2m$$$.Now we just have to select $$$2m$$$ numbers from $$$[2,n+2m]$$$ or scaling down choose from $$$[1,n+2m-1]$$$.This can be done in $$$\binom{n+2m1}{2m}$$$

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          I didn't understand sequence di=ci+i part.Can you please elaborate it.

          • »
            »
            »
            »
            »
            »
            5 years ago, # ^ |
            Rev. 2   Vote: I like it +4 Vote: I do not like it

            See for all $$$1\leq i\leq 2m-1$$$ $$$c_{i+1}\geq c_i\implies (d_{i+1}-{i+1})\geq (d_i-i)\implies d_{i+1}\geq 1+d_i>d_i$$$.Also $$$c_1\geq 1\implies d_1\geq 2$$$ and $$$c_{2m}\leq n\implies d_{2m}\leq n+2m$$$.Hope this is clear.The bijection part just asserts that the number of ways of choosing $$$2m$$$ numbers of $$$c_i$$$ form is same as that of choosing $$$2m$$$ distinct terms from $$$d_i$$$

            • »
              »
              »
              »
              »
              »
              »
              5 years ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              How do you think about declaring di=ci+i. Is it a common practice to remove equality?

              • »
                »
                »
                »
                »
                »
                »
                »
                5 years ago, # ^ |
                  Vote: I like it +1 Vote: I do not like it

                Its fairly well known in the math community and yeah I can understand that this feels like magic but its a nice trick.If you read about Stars and Bars then this becomes easier to grasp.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 years ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Any good resources for strengthening combinatorics for CP? I did solve the problem but wasn't able to come up with the closed form/

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 years ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Yes, i too am is in search of a good resource to improve in combinatorics used in CP

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Beautiful Idea. Especially to remove the inequality !

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +4 Vote: I do not like it

        Since we have to choose a non-decreasing sequence (Xi) of length 2m. 1<=Xi<=n.

        consider this sequence... S:= 1 1 1 1.......2 2 2 2......3 3 3 3....n n n n n..... (where i i i… repeats 2m times). Now we have two find no of ways of choosing a non-decreasing sequence of length 2m form S. This is exactly same as finding no of solution of the linear equation X1 + X2 + X3 +.....+ Xn = 2m. where Xi denotes how many time i appears in the chosen sequence. so clearly Xi can takes value from 0 to 2m. and hence this linear equation can be solve by standard classical mathematics i.e. finding coefficient of 'x^2m' in the polynomial P(x)=(1+x+x^2+...+x^2m)*(1+x+x^2+...+x^2m)*....*(1+x+x^2+...+x^2m)... n times for each Xi.

        One more trick:= (1+x+x^2+...+x^2m) can be replace by (1+x+x^2+...+x^2m+....) infinite sum since x^(2m+1) and higher power doesn't contribute in coefficient of x^2m(that we are interested in)

        Now we are done P(x) reduces to p(x)= 1/(1-x)^n

        and there is standard famous formula for ...

        coefficient of x^r in 1/(1-x)^n is — (n+r-1)C(r).

        Since r=2m here so answer is (n+2m-1)C(2m).

  • »
    »
    5 years ago, # ^ |
    Rev. 4   Vote: I like it +30 Vote: I do not like it
    a[1]<=a[2]<=a[3]<=a[4] .. a[m]
    b[1]>=b[2]>=b[3]>=b[4] .. b[m]
    and a[i]<=b[i] for every i (1 --> m)
    so we can merge the two arrays into one array like that 
    a[1] a[2] a[3] ... a[m] b[m] b[m-1] b[m-2] ... b[1]
    then we can solve it with dp[last][i] 
    and for every element i we can assign any number large than a[i-1] (last) and less than n 
    

    check this 68817461

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      Beautiful solution + explanation, Thanks.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      can you please explain a little bit why we can assign any number large than a[i-1] even though the i is larger than m, I'm confused because b should be decreasing

      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 2   Vote: I like it +5 Vote: I do not like it
        A=1 2 3 4 4 
        B=9 8 8 7 6 
        This is one correct example B is decreasing and A is increasing and every Ai<=Bi
        So reverse B and put it after A
        So A = 1 2 3 4 4 6 7 8 8 9 
        It is really increasing and all conditions are true .. because of that we can just build an increasing array with size m+m .. 
        I hope i explain it well !
        
        
    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      How did you think. Nice solution :)

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    :)) cin >> n >> m; cout << C(n + 2 * m — 1, n — 1);

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Can you explain ?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        count the number of ways to arrange number from 1 to n into array 2 * m length is sorted in non-descending order. That is combination with repetition C(2 * m + n — 1, n — 1)

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Suppose m=6 ,A=[1,2,2,3,4,5] and B=[9,8,7,7,5,5] Now make a new array X of size 2*m whose first m elements are same as A and next m elements are same as B but in reverse direction. So new array becomes- X= [1,2,2,3,4,5,5,5,7,7,8,9] The new array X is non decreasing in nature. So basically for every correct pair of A and B, its X will be non-decreasing in nature. So, you basically have to find number of possible non decreasing array of size 2*m whose elements are between 1 to n. This could be easily calculated using dp.

    Code- (http://mirror.codeforces.com/contest/1288/submission/68824571)

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The dp solution I implemented is O(N^2 * M). Is there a faster time-complexity solution that involves dp?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Same

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        I implemented it in O(n*m^2), first choosing the maximum element as i which can reside in first array and then second array can choose elements only from n-i+1 numbers and then use stars and bars technique for both the arrays

        My solution : https://mirror.codeforces.com/contest/1288/submission/68829446

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I did the same DP. The states of DP maintain a range of possible values for both sequences.

        Actually the range itself doesn't matter, just its length — we use it to check if the range is non-empty after increasing the lower bound or decreasing the upper bound.

        Then it's easy to code the DP in $$$O(n*m)$$$. my cpp code

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The final statement that you wrote can be solved using combinatorics. I claim that any strictly increasing sequence with elements between 2 to n+2m, can be converted into non decreasing sequence with elements between 1 and n, by decreasing each element's value by its index. Since the number of ways for the first problem is same as the number of ways to select 2m numbers from n+2m-1 numbers, that'll be our answer for the second question as well. Tl:Dr: Answer is C(n+2m-1,2m).

»
5 years ago, # |
  Vote: I like it +3 Vote: I do not like it

How to solve D?

  • »
    »
    5 years ago, # ^ |
    Rev. 7   Vote: I like it +7 Vote: I do not like it

    Use bit masks to know for each line the minimum value of each mask of it, then combine the best mask and ((1<<m)-1 ^ mask) to find the answer

  • »
    »
    5 years ago, # ^ |
    Rev. 3   Vote: I like it +26 Vote: I do not like it

    You do a binary search on the answer. Then for checking if an answer $$$x$$$ is valid, you can make a $$$m$$$ bit mask for every array in which $$$i$$$th bit is $$$1$$$ if $$$a[i]$$$ is greater than $$$x$$$. The problem now is to find two arrays so that bitwise or of the mask of two arrays is equal to $$$2^m - 1$$$. For that you can just fix one array and brute force all possible masks which complement current mask (which are less than $$$2^m$$$) and find if the mask is among the mask of all arrays. If there is one then the answer $$$x$$$ is valid otherwise no.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it -40 Vote: I do not like it

      Thanks, it is very clear. Binary search over x is log(1e9)=1e3. And n=3e5. So, 3e8 in total, I thought it would TLE so did not even consider this way. Brute over bit masks is cool, I did not get to this point on contest. Thanks.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        log(1e9) = ~30 not 1e3

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it +3 Vote: I do not like it

          My bad

          log(1e9) * 8 * 3e5 = 30 * 8 * 3e5 ~= 1e8. A bit better =)

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I got TLE on test 21 :( I think I used some unnecessary sets that added an undesired log factor

      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        I also used unnecessary sets. Was lucky to have got it passed in 4.7 seconds. My complexity was $$${2^m}*n*m*\log{10^9}$$$. Later I realized it was possible to do it in $$${(n*m+{4^m})\log{10^9}}$$$. The latter passed in 0.9 seconds.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Thanks a lot RetiredProgrammer .

      Can you explain a bit how this solution works. Actually I don't understand the part where we find two array so thats bitwise or of the mask of two arrays is equal to 2^m−1. I have not much idea about bismask but I know in k size bit we have store something in every bit whether the postion is true or false. Set bit 1 , 0. This type of basic idea.

      Thanks again :)

      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 4   Vote: I like it +6 Vote: I do not like it

        Assume you are trying to find an answer that has score of at least $$$x$$$. We can now convert each array into a mask of $$$m$$$ bits where the $$$j$$$-th bit is $$$1$$$ if $$$a_{i, j} \geq x$$$, and $$$0$$$ otherwise.

        As there are only $$$2^m \leq 256$$$ distinct possible masks, you can easily store, for each mask, the index of an array that matches it, or a "nil" value if no arrays match it. Then bruteforce pairs of masks; if they both have valid indices and complement each other (i.e. $$$mask_a \vee mask_b = 2^m - 1$$$, where $$$\vee$$$ is the binary "or" operator), there is a result with a score of at least $$$x$$$.

        We can then binary search for the maximum $$$x$$$ score that returns a valid answer.

        My final time complexity is $$$O((nm + 2^{2m})\log(\max a_{i,j}))$$$ (68838510)

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          I've tried binary search + bitmask solution and it got accepted. Then I see the dp tag on this problem. Is there any dp involved here? or there is another dp solution?

          • »
            »
            »
            »
            »
            »
            5 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Tags only imply that it's possible to use a technique to solve the problem, and not necessarily that the technique must be used to solve the problem. I'm not exactly sure how to use DP to approach this problem though.

            • »
              »
              »
              »
              »
              »
              »
              5 years ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              Yeah, even the editorial uses the exact approach described by you. No dp at all.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          It seems like they have written dp as there is a small dp modification which can reduce the comp to (nm+2^m)(log(max))

          • »
            »
            »
            »
            »
            »
            5 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Hm. I can see how to reduce it to $$$O((nm + 3^m) \log \max a)$$$ (for each bit position, there are three valid pairs of bits), but not $$$... 2^m ...$$$

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +18 Vote: I do not like it

    For each array and for each mask (out of $$$2^m$$$ of its indexes) calculate a minimum value. Then go through the input and for each array $$$i$$$ enumerate all masks $$$M$$$. Between all masks $$$M$$$ calculate maximum value of minimum(calculated minimum for mask $$$M$$$ of array $$$i$$$, maximum of calculated minimums for mask $$$2^m - 1 - M$$$ of all already processed arrays). The second value can be updated on the fly.

    Why this works
»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

Veeeeery interesting!

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks a lot for your insightful explanation to D ! I learnt a lot from this beautiful problem !

»
5 years ago, # |
  Vote: I like it +56 Vote: I do not like it

Clearly, Numberphile made this contest

»
5 years ago, # |
  Vote: I like it +28 Vote: I do not like it

Can anyone share a solution to F?

»
5 years ago, # |
  Vote: I like it +2 Vote: I do not like it

how to solve B

  • »
    »
    5 years ago, # ^ |
    Rev. 3   Vote: I like it +4 Vote: I do not like it

    The answer for a given pair (A, B) is A * the count of numbers of the form 9, 99, 999, 9999, 99999.... that are less than or equal to B.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +2 Vote: I do not like it

    Basically a pair (a,b) is valid if and only if b is of the form 99...9. Therefore, you just need to count the number of numbers of this type between 1 and B and multiply by A.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    a*b+a+b=a*10^p+b ==>b+1=10^p

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Fix the length of $$$b$$$ and name it $$$i$$$. It can be between $$$1$$$ to $$$10$$$. Then we have $$$a \times b + a + b = a + 10^i \times b$$$. It simplifies into $$$b = 10^i - 1$$$. So no matter what $$$a$$$ is, $$$b$$$ is $$$10^i - 1$$$. So just check if $$$10^i - 1$$$ is between $$$1$$$ and $$$B$$$ and if it is add $$$a$$$ to the answer.

»
5 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Can someone please explain the solution to D ?

»
5 years ago, # |
Rev. 4   Vote: I like it +8 Vote: I do not like it

Happy Hacking in 1288F - Red-Blue Graph 68818026 !!! System test passed!! awoo it should be ok?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Whould you be so kind to explain what is going on in your solution?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Should've set the constraints higher :^) It's ok I guess but minimum cost circulation was the intended solution.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve B

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Math shows that $$$b$$$ in the formula has to be of the form 999999...9, and $$$a$$$ doesn't matter.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    a*b+a+b=conc(a,b). Let number of digits in b be d,then conc(a,b)=a*(10^d)+b. a*b+a+b=a*(10^d)+b a*b=a*(10^d-1), a!=0. b=10^d-1. hence b=9,99,999,.....99999999,as b<=10^9. So find the number of b's less than B,call it temp. Answer is temp*a.

»
5 years ago, # |
Rev. 2   Vote: I like it +2 Vote: I do not like it
  • »
    »
    5 years ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Because when n > O(sqrt(d)), It always success. so that code must done O(sqrt(d))

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

By looking closely at conditions given in $$$C$$$, we see that $$$a_{1} <= a_{2} <= .... <= a_{m} <= b_{m} <= b_{m-1} <= .... <= b_{1}$$$.

So, why does choosing any $$$2*m$$$ elements not work, i.e. why is $$$n^{2*m}$$$ wrong. I don't understand, can someone please help me clear this up.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +9 Vote: I do not like it

    The reasoning isn't wrong at all. Choosing $$$2*m$$$ elements that satisfy that condition would work. But $$$n^{2*m}$$$ is not the way to count that, since you are counting sequences that are invalid. This number is the total number of sequences of lenght $$$2*m$$$ some of which doesnt satisfy that condition.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yeah, I just realised this is overcounting all permutations. Thanks for your reply.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    You are overcounting.Say for eg if the $$$a_i$$$ and $$$b_i$$$ are $$$1,1,2,2$$$ then you count this as number.Then you also count $$$1,2,1,2$$$ and all permutation of it when you shouldnt be.To count the desired number we have to use stars and bars.

»
5 years ago, # |
Rev. 2   Vote: I like it -56 Vote: I do not like it

.

»
5 years ago, # |
  Vote: I like it +9 Vote: I do not like it

Am I the only one who did C with 2-D prefix sums?)

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    no ...i also did the same

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Me too, and also KrK. Though it was a very easy formula :(

  • »
    »
    5 years ago, # ^ |
      Vote: I like it -6 Vote: I do not like it

    nope

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can you please share your approach ?

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 2   Vote: I like it +3 Vote: I do not like it

      Let dp[k][i][j] will be number of valid arrays with length k and with a[k]=i and b[k]=j; So to get dp[k][i][j] we need all the dp[k-1][l][r] with l<=i and r>=j. How can we calculate it fast? Let's do 2*D prefix sums on dp[k-1][i][j] for all possible i and j. So formula is: dp[k][i][j]=pref[i][n]-pref[i][j-1]. Where pref[x][y] is sum of all dp[k-1][i][j] where i<=x and j<=y. https://mirror.codeforces.com/contest/1288/submission/68798026

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I simpler way is including transitions that deal with it.

        $$$dp[k][i][j] = dp[k-1][i][j] + dp[k][i + 1][j] + dp[k][i][j - 1] - dp[k][i + 1][j - 1]$$$

        And we get a nice $$$O(n^2*m)$$$ solution.

        We can further improve it because $$$i$$$ and $$$j$$$ don't matter just $$$j-i+1$$$. That makes it $$$O(n*m)$$$. code

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          hey excellent transition. Could you provide a little explanation on why i , j dont matter just length j-i+1 enough . did u mean dp[k][3][5] == dp[k][4][6] ?

          • »
            »
            »
            »
            »
            »
            5 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Yes, $$$dp[k][3][5] == dp[k][4][6]$$$.

            We just use $$$i$$$ and $$$j$$$ to check if the range is non-empty, $$$dp[k][i][j] = 0, \text{if }i > j$$$.

            You can also think that we will always normalize the range so that $$$i = 1$$$, eg [6, 10] -> [1, 5]. As $$$i$$$ is constant it can be remove from the state.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Can you please explain the transition formula a bit more.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I solved using suffix sum. My relation came dp[i][j]= dp[i-1][j] + suffix_sum[i][j].

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Me too, buddy ^.^

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

"You should be eligible for ICPC and/or IOI 2020+" I have second priority of bootcamp invite letter... But could not participate due to the above conditions.... So sad ;-;

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I used binary search for D, is there any other method to do it in the given constraints?

»
5 years ago, # |
  Vote: I like it +9 Vote: I do not like it

My idea for problem A:

Getting $$$\min \left(x + \left \lceil \dfrac{d}{x + 1} \right \rceil \right )$$$ is the same as getting $$$\min \left(x + 1 + \left \lceil \dfrac{d}{x + 1} \right \rceil \right ) - 1$$$.

Then let $$$a = x + 1$$$, we should get $$$\min \left(a + \left \lceil \dfrac{d}{a} \right \rceil \right )$$$. Because we know $$$a + b \ge 2\sqrt{ab}$$$, I thought $$$\min \left(a + \left \lceil \dfrac{d}{a} \right \rceil \right )= \left \lceil 2 \sqrt{d}\right \rceil$$$. My code is here:

typedef long long LL;
cin >> n >> d;
LL tot = (LL)ceil(sqrt(d) * 2LL);
cout << (tot <= n + 1 ? "YES" : "NO") << endl; 

But now I think there's something wrong with it, that's becase of $$$\mathrm{ceil}$$$. Could you please HACK my solution, or tell me if it's right?Thanks.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    I just made sure to check the area +/-1 of sqrt(d) just to be safe.

  • »
    »
    5 years ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    Can you explain why did you take the ceil of sqrt(d)*2 ?

    a + (d/a) >= 2*sqrt(d)

    so, a + ceil(d/a) >= 2*sqrt(d) ?

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      $$$a + \dfrac{d}{a} \ge 2 \sqrt{d}$$$ is of course right, and $$$a + \left\lceil\dfrac{d}{a} \right \rceil \ge 2 \sqrt{d}$$$ is also obvious (Because $$$\left\lceil\dfrac{d}{a} \right \rceil \ge \dfrac{d}{a}$$$ ). But I can't proof $$$a + \left\lceil\dfrac{d}{a} \right \rceil \ge \left \lceil 2 \sqrt{d} \right \rceil$$$ .

      I'm wondering it. That's just the reason I post this comment. But it seems that I have passed the system test?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Couldn't it be the case that 2√d <= n but a + d/a > n?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve E?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

    Minimum position is 1 or i, we only need to calculate max now. Let's find first position of i, before i becomes first every number larger than x changes position by one, so it's 1 + number of distinct integers larger than i before this position. Now between 1st position and 2nd, 2nd and 3rd, and so on, it's position is just 1 + number of distinct integers in range. This stuff can be calculated with segment trees.

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it +18 Vote: I do not like it

    Also, you could simulate the whole process.

    In the beginning, $$$min_i = max_i = i$$$. When some element moves to the front, you set $$$min_i = 1$$$ and $$$max_i = max(max_i, a)$$$, where $$$a$$$ is its current position (because it is the element's rightmost position before it will be moved to the front). In the end, you update $$$max_i$$$ for every $$$i$$$ again, based on the positions of the elements in our sequence.

    The insertion/deletion operations can be done with ordered_set, treap in $$$O(n + m \log n)$$$, or with split-rebuild sqrt decomposition in $$$O(n + m \sqrt n)$$$, 68820376, if you want to have fun.

    P.S. This approach is quite structure-heavy, less thinking, more implementing (which makes it not really beautiful).

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +11 Vote: I do not like it

      Haha, I set time limit generously to let any sqrt/log^2 distinct value queries pass but I'm glad this passes as well :D

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +10 Vote: I do not like it

      Fenwick tree of size $$$n+m$$$ works as well, probably a bit easier to implement.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Fenwick tree+PBDS solution: Code

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

In problem A, shouldn't be the output of:

1

18 88

be "NO"? Shouldn't the minimum days required be 19 and not 18? My hack was unsuccessful for a solution giving output: "YES" for above case. Is the checker solution ignoring the ceil function mentioned in the question?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Please explain DP approach for C?

  • »
    »
    5 years ago, # ^ |
    Rev. 6   Vote: I like it 0 Vote: I do not like it

    You can count how many arrays start with $$$i$$$, are length $$$j$$$, and are non-decreasing by using

    $$$D(i, j) = \sum_{k = 1}^i D(k, j - 1),$$$

    and how many arrays start with $i$, are length $$$j$$$, and are non-increasing by using

    $$$E(i, j) = \sum_{k = i}^n E(k, j - 1).$$$

    The answer is then

    $$$\sum_{k = 1}^n \left( E(k, m) \cdot \sum_{l = 1}^k D(l, m) \right ).$$$
  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    dp state could be dp[i][j] , i the curent position in the array we are placing integers on, j curent difference between the numbers on i-1 position

»
5 years ago, # |
  Vote: I like it +18 Vote: I do not like it

I'm getting Illegal Contest ID when I try to hack any solution.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Go to submissions tab of the user and hack from there by opening the link (and not the popup).

»
5 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

code problem C:
cout << C(n + 2 * m — 1, n — 1);

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    How you arrived at this solution?

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +2 Vote: I do not like it

      If you reverse the array A and append it to the back of B, then the sequence is decreasing (cause b[0]>=b[1]>=b[2]>=....>=b[m-1]>=a[m-1]>=a[m-2]>=...>=a[0]). Hence you need to find the number of decreasing sequences of length 2*m. Let x1,x2,x3,..,xn be the number of times 1,2,3...n have occurred. Then the number of solutions of x1+x2+x3+...+xn=2*m is the required answer (cause the order is fixed after choosing).

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Wow, that's the most elegant approach! Thanks.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it -6 Vote: I do not like it

        My solution was precisely the same. Here is (main part of) my actual solution:

                        long dp[][]=new long[n+1][2*m+1];
                        for(i=0;i<=n;i++){
                            dp[i][1]=i;
                            dp[i][0]=1;
                        }
                        for(j=2;j<=2*m;j++){
                            for(i=1;i<=n;i++){
                                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
                            }
                        }
                        out.println(dp[n][2*m]);
        
  • »
    »
    5 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

»
5 years ago, # |
  Vote: I like it -61 Vote: I do not like it

I spent more than an hour in C because 3rd sample test itself was failing. Later on realised that I had written mod = 100000007 instead of 1000000007. So didnt get time to solve problem D.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +30 Vote: I do not like it

    It might be convenient to use 1e9 + 7 when modulo = 1000000007, as it's both easier to read and less prone to mistakes :)

»
5 years ago, # |
Rev. 5   Vote: I like it +53 Vote: I do not like it

EDIT: now with a (actually) working min-cost flow :Dd 69056043

Solution to F
  • »
    »
    5 years ago, # ^ |
    Rev. 5   Vote: I like it +10 Vote: I do not like it

    Hey in the function minCostCirc() shouldn't the line: if (edges[ei].ru & h) res += incEdge(ei, h);

    be changed to: if (edges[ei].ru & h) res += (h*incEdge(ei, h));?

    (Since the new cost = previous cost + (flow added * cost of the negative cycle ).)

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 2   Vote: I like it +8 Vote: I do not like it

      Well spotted. Turns out that in every problem I tested my code on, either the cost didn't matter (only the flow along each edge in an optimal flow did) or the capacity of every edge with nonzero cost was 1 :Dd

      I submitted the fixed code to min-cost max-flow on kattis, so it should definitely now work.

»
5 years ago, # |
  Vote: I like it -37 Vote: I do not like it

Which is the math explanation for A

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

My solution for A is a bit different. Its enough to check on just x = (n/2),(n/2 + 1), and (n/2 — 1). Its because I think in the optimal solution both terms on the LHS in x + d/(x+1) = n (in worst case) should be equal or close enough. This means x = n/2 or around that.

Can anybody hack this?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    i also did it this way

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    It's not correct. Function f(x)=n/(x+1)+x has the smallest value in point sqrt(n)-1

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Then n/(x+1)+x will be equal 2*sqrt(n)

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +10 Vote: I do not like it

      You need to notice that he said $$$\dfrac{n}{2}$$$ and not $$$\dfrac{d}{2}$$$.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +28 Vote: I do not like it

    Its not possible to hack this, because it is always correct.

    Proof: We need $$$x + \lceil \dfrac{d}{x+1} \rceil <= n$$$. Since $$$ \lceil \dfrac{d}{x+1} \rceil <= \dfrac{d}{x+1} + 1$$$, we try to solve $$$x + \dfrac{d}{x+1} + 1 <= n$$$.

    $$$ y + \dfrac{d}{y} <= n $$$,

    $$$ y^2 - n*y + d <= 0 $$$

    $$$ ( y - a ) ( y - b ) <= 0 $$$, which means $$$y$$$ must be between both roots, so that we get negative sign.

    i.e. $$$x+1$$$ should be between both roots. Also, both roots are centered around $$$\dfrac{n}{2}$$$, so this will always be true, if you take few possibilities around $$$\dfrac{n}{2}$$$ for values of $$$x$$$.

»
5 years ago, # |
  Vote: I like it +27 Vote: I do not like it

What's the intended solution for 1288F - Red-Blue Graph?

»
5 years ago, # |
  Vote: I like it +7 Vote: I do not like it

can anyone give me a tricky case for A?? I would like to see if my code is OK

»
5 years ago, # |
  Vote: I like it +1 Vote: I do not like it

What is the meaning of non-ascending? Isn't the array $$$[1, 2, 5, 4]$$$ non-ascending because, well, it is not ascending?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +16 Vote: I do not like it

    It says "sorted in non-ascending order" not just "non-ascending".

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +6 Vote: I do not like it

      Well, when they say sorted in some order, the ordering is often clear. For example, if they say sorted in alphabetical, lexicographic, ascending or descending, it is known what they mean or even then in some cases, they explicitly define the ordering.
      What kind of ordering does non-descending or non-ascending establish?
      I understand from here that it is fairly obvious to everyone who got an AC and even to several others, but it wasn't obvious to me. I just feel it should have been defined for the benefit of participants.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      A quick Google search found the definitions of these terms but only in the context of the ambiguities that arise out of using them :)
      I hope that contest setters will define their terms in upcoming contests.

      Anyway, I feel that despite this I stumbled upon an interesting problem. How would you approach problem C if non-descending is to be interpreted as not descending and non-ascending as not ascending.
      For example, if $$$[1, 2, 3, 4]$$$ and $$$[3, 2, 1, 5]$$$ are non-descending (say).

      I spent the entirety of the contest and much later trying to solve this but couldn't. Any ideas?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I understand the term "sorted ascending" as every element is bigger than the previous one, and "sorted non descending" as every element is not smaller that the previous one.

        But basically it is the same, it works to simply see both as one and the same.

      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 4   Vote: I like it +3 Vote: I do not like it

        For solving the new question that you have raised,

        We need to find number of arrays $$$(a,b)$$$ such that $$$a$$$ is not descending ($$$ND$$$) and $$$b$$$ is not ascending ($$$NA$$$).

        Simple inclusion exclusion gives,

        number of ways $$$(a,ND,b,NA)$$$ = $$$all(a.b)$$$ — $$$(a,D)$$$ — $$$(b,A)$$$ + $$$(a,D,b,A)$$$

        $$$(a,D)$$$ denotes $$$a$$$ is descending. ( note $$$b$$$ can be anything here ).

        $$$(a,D,b,A)$$$ denotes $$$a$$$ is descending AND $$$b$$$ is ascending.

        Now, $$$all(a,b)$$$ is straightforward. So is $$$(a,D)$$$ and $$$(b,A)$$$. And, for $$$(a,D,b,A)$$$ we can use the method that was required to solve Original $$$C$$$ of the contest.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          How would you solve $$$(a, D)$$$? This is precisely where I was stuck.

          • »
            »
            »
            »
            »
            »
            5 years ago, # ^ |
            Rev. 2   Vote: I like it +3 Vote: I do not like it

            $$$(a,D)$$$ is number of ways of choosing array $$$a$$$ of length $$$m$$$ with values between $$$1$$$ and $$$n$$$, such that it's elements are in descending order, ( and $$$b$$$ can be anything, so we must multiply a factor of $$$n^{m}$$$ ).

            Now, number of descending depends a lot on your exact definition of "descending". Is it "strictly descending"? Is $$$[5,3,3,2,2]$$$ descending?

            If you want only strictly descending, then you just need $$$m$$$ distinct values ( because "strictly" forces no repitition of values ). So final $$$(a,D)$$$ will be $$$ choose(n,m) * n^{m} $$$. ( $$$choose(n,m)$$$ chooses $$$m$$$ distinct values from $$$n$$$ possible values, and there is only one "strictly descending" ordering of these $$$m$$$ chosen values. )

            If your definition of descending array allows equal values, then we have the following equation to solve:

            $$$x_n + x_{n-1} + x_{n-2} + .... + x_3 + x_2 + x_1 = m$$$

            $$$x_{i}$$$ denotes number of $$$i$$$s that we take in our array. We must find all non negative ( $$$x_i >= 0$$$ ) solutions of the equation, which is given by $$$choose(n+m-1,n-1)$$$. You can read more about Stars and Bars.

            So, answer in this case would be, $$$(a,D) = choose(n+m-1,n-1)*n^{m}$$$.

            • »
              »
              »
              »
              »
              »
              »
              5 years ago, # ^ |
              Rev. 2   Vote: I like it 0 Vote: I do not like it

              $$$b$$$ cannot be anything. $$$a_i <= b_i$$$ for all $$$i$$$ has to still hold for the inclusion-exclusion calculation to hold. P.S. Thanks for the link.

              • »
                »
                »
                »
                »
                »
                »
                »
                5 years ago, # ^ |
                Rev. 2   Vote: I like it 0 Vote: I do not like it

                This can be done with dp, instead of formuales directly. ( Maybe it could be done with formulaes, but I can't think of it ).

                Let $$$dp[i][j]$$$ be number of ways to choose both $$$a[i]$$$ and $$$b[i]$$$ with $$$a[i] = j$$$

                So, we must use $$$dp[i-1][x]$$$ where $$$ x >= j $$$ to make this result, and when $$$a[i]=j$$$, $$$b[i]$$$ can take $$$n-j+1$$$ values ( $$$j, j+1, j+2, ... n$$$ ). ( Note, $$$b[i]$$$'s are independent of each other ).

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

In problem A test case 22 inputs are

63243 999950885

The judge says the answer is No but if he works 31620 days on optimizing, his program will work in 31623 days and will fit the limit.

Am i doing somrthing wrong? awoo

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Nevermind I was wrong :| Sorry.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anybody suggest easier or similar problem , based on same concept like D?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

My rating hasn't changed after this contest and also this contest is not appearing in myProfile-> contests list. Can anybody explain?

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it +16 Vote: I do not like it

    Due to some reasons, Codeforces hasn't updated ratings for everyone yet. We just have to wait for a little longer.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it -7 Vote: I do not like it

      For me, the wait is worth it! :D

»
5 years ago, # |
  Vote: I like it +10 Vote: I do not like it

How to solve c if both arrays are non decreasing?

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

    The only thing I came up with is the following. Let $$$dp[i][j][k]$$$ be the number of such arrays of size $$$i$$$ with $$$j$$$ and $$$k$$$ being the last elements of $$$a$$$ and $$$b$$$ respectively. Then $$$dp[i][j][k] = \Sigma dp[i-1][x][y]$$$ for all $$$1 \leq x \leq j$$$ and $$$1 \leq y \leq k$$$. We can maintain these sums using prefix sums. The total runtime will be $$$O(mn^2)$$$.

»
5 years ago, # |
  Vote: I like it +89 Vote: I do not like it

Why the rating hasn't changed?There is always change in two hours,but now is after the open hacking about five hours?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can't wait so long to become Master :/

»
5 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Does anyone know when the system testing starts?

»
5 years ago, # |
  Vote: I like it +7 Vote: I do not like it

EDitorial Please of Educational Round 80

»
5 years ago, # |
  Vote: I like it +24 Vote: I do not like it

Soo... Is it ratted?

»
5 years ago, # |
  Vote: I like it +7 Vote: I do not like it

To be honest, I haven't met such situation. So who can tell me what's the matter with codeforces?

»
5 years ago, # |
  Vote: I like it +17 Vote: I do not like it

Waiting for 4 hours already !!

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Is there a better way to do A other than binary search?

I tried binary search but it fails on test 50.

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

    Yes, here's a $$$O(1)$$$ solution. $$$x + \lceil \dfrac{d}{x + 1} \rceil \leq n \iff \lceil \dfrac{d}{x + 1} \rceil \leq n - x \iff d \leq (n - x)(x + 1) \iff x^2 + (1-n)x + (d-n) \leq 0.$$$ This inequality has solutions in real nonnegative numbers if and only if $$$(n - 1)^2 \geq 4(d - n)$$$. Actually, working under assumptions of the problem, it has nonnegative integer solutions if and only if it has nonnegative real solutions, so we just need to check the inequality $$$(n - 1)^2 \geq 4(d - n)$$$ to obtain the answer. https://mirror.codeforces.com/contest/1288/submission/68780664

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    choose x to be n/2 or (n + 1) / 2

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      should be sqrt(x) or sqrt(x)+1, and just to be save, better check all x from sqrt(x)-3 to sqrt(x)+3 for optimal value.

»
5 years ago, # |
  Vote: I like it +8 Vote: I do not like it

How on earth happens with codeforces rating calculating system?

»
5 years ago, # |
  Vote: I like it +7 Vote: I do not like it

When the new ratings will be available? Can anyone tell that?

»
5 years ago, # |
  Vote: I like it +7 Vote: I do not like it

Why is the rating changes not published even after 6 hours of completion of open hack phase?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

During and after the contest there were no signs of any issues with the tests or whatsoever, so we should keep our faith strong.

»
5 years ago, # |
  Vote: I like it +7 Vote: I do not like it

1288A - Deadline can be solved using the first derivative of f (x) = x + d / (x + 1) because when this is 0 it is because this point is a minimum, here we see the third case of the example:  the derivative gives us: 1 — d / (x + 1) ^ 2 and if we equal it to zero it gives us x = sqrt (d) — 1, if we substitute this in the original function it results in (2 * d — sqrt ( d)) / sqrt (d), if this value is less than n then we print "YES" or else "NO". My submission is 68818558

»
5 years ago, # |
  Vote: I like it +5 Vote: I do not like it

what is wrong in codeforces system?

»
5 years ago, # |
  Vote: I like it +44 Vote: I do not like it

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It has been more than 6 hours until open hacking finished. System testing didn't even start yet! I feel like codeforces is having a problem with something!

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    The system testing actually finished at about 7 hours ago! <D

»
5 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Why didn't the rates changed till now?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Before rating changes, there is system testing. So all the hacks would be added to the main tests. System testing didn't even start!!

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Actually, it has already finished several hours ago.

»
5 years ago, # |
  Vote: I like it +2 Vote: I do not like it

meanwhile we could check our ratings here https://cf-predictor-frontend.herokuapp.com/

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You are absolutely correct! But those ratings are not accurate. Some people may fail system testing! Lets hope that codeforces starts system testing very soon.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      There was systesting

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Oh, my bad. I didn't realize that! Thanks for informing me!

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      system testing is done ig

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      yeah you've got a point ,lets hope they start system testing soon enough

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 2   Vote: I like it +4 Vote: I do not like it

      System Testing is finished I got a wrong answer on D and it was Ac yesterday ! But idk why the rating didn't update yet .

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        Me too. Added a +7 to my infinity and i got accepted. Feels bad man.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
          Rev. 2   Vote: I like it +8 Vote: I do not like it

          Sorry for u :( I start my for loop from 0 instead of 1 to get AC .. But the good thing i solved it afer the contest(it is not rated for me) :D

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    But sometimes its prediction is a little bit wrong.

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

when will be the rating updated

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

Isn't it already too late for results?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

when will rating changes come out ?

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

At least, someone please tell the reasons behind the delay.

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

When it will be rated ?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Finally, ratings got updated!

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

can some one explain how to solve problem E . I have knowledge of segment trees and BIT . But i have not solved much problem on them .

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Refer this comment for the solution approach of Problem E

    If you know basic segment tree but do not know how to find range distinct queries, then you can see the accepted answer of this stackoverflow question. Its explained in very easy to understand language.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

old submission wrong on test case 50 which was Input

2

63242 999919263

63242 999919264

Participant's output

YES

YES

Jury's answer

NO

NO

new submission

this i used long double which solved the error

can anyone tell me why.

the ranges were 1<a,b<10^9 for which i think float would have worked fine

»
5 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Editorials?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
5 years ago, # |
  Vote: I like it +23 Vote: I do not like it

Will we get to know who won the prize?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Please attach the announcement and editorial to the questions.